2016-12-14 100 views
0

正如許多線程中所建議的,我嘗試通過以下cURL組合觸發jenkins作業,但似乎沒有任何工作。如何觸發Jenkins從cURL構建?

curl -X POST http://localhost:8080/job/someJob/build?delay=0sec --user user:password 
curl -X POST -u user:password http://localhost:8080/job/testjob/build 

但是我得到:

<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/testjob/build. Reason: 
<pre> No valid crumb was included in the request</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/> 
</body> 
</html> 

我試着用郵遞員,wget的還是同樣的問題。請建議

+0

Duplicate?http://stackoverflow.com/questions/28577551/how-to-disable-a-jenkins-工作通過捲曲 http://stackoverflow.com/questions/38137760/jenkins-rest-api-create-job http://stackoverflow.com/questions/23497819/trigger-parameterized-build-with-curl- and-crumb – MaTePe

+0

@sajibkhan它給出的語法問題。 – simplysifar

+0

@MaTePe感謝您建議的鏈接,首先在e解決了這個問題:CRUMB = $(curl -s'http:// git:git @ localhost:8080/crumbIssuer/api/xml?xpath = concat(// crumbRequestField,「:」,// crumb)') curl -X POST -H $ CRUMB -u git:git http:// localhost:8080/job/testjob/build – simplysifar

回答

0

首先跌破發行捕捉碎塊 CRUMB = $(捲曲-s「的git:git的@本地:8080/crumbIssuer/API/XML的XPath = CONCAT(// ...) 然後: curl -X POST -H $ CRUMB -u git:git localhost:8080/job/testjob/build