背景介绍
开发的jenkins job 在local的 一台windows 上,而我们测试的jenkins job 在azure 上的一台windows server 2012 上。由于 azure上机器的网络比local的网络好,所以测试不愿意把测试job建在开发的jenkins上,开发也觉得迁移自己的job到azure上麻烦。那我们只能使用Remote access API(https://wiki.jenkins.io/display/JENKINS/Remote+access+API) ,来让开发的job 主动来触发在azure的测试job。
使用如下命令来让local 的jenkins job 去主动触发 azure上测试的jenkins job
curl -X POST http://168.192.10.78:8080/job/AndroidTestCase/build --user xiaohua:3a2522f75356f6791f6040bf9ee3808b
执行后在jenkins出现如下错误:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 403 No valid crumb was included in the request</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /job/AndroidTestCase/build. Reason:
<pre> No valid crumb was included in the request</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>
解决方案:
在jenkins 的Configure Global Security下 , 取消“防止跨站点请求伪造(Prevent Cross Site Request Forgery exploits)”的勾选。(如下图)