0

As suggested in many Stack Overflow questions I have tried triggering the Jenkins job via the following cURL combinations. However, none seems to work.

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

However, I am getting:

<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>

I tried using Postman, but wget still has the same issue.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
simplysifar
  • 11
  • 1
  • 5
  • Duplicate? http://stackoverflow.com/questions/28577551/how-to-disable-a-jenkins-job-via-curl http://stackoverflow.com/questions/38137760/jenkins-rest-api-create-job http://stackoverflow.com/questions/23497819/trigger-parameterized-build-with-curl-and-crumb – MaTePe Dec 14 '16 at 13:28
  • @sajibkhan its giving syntax issue. – simplysifar Dec 14 '16 at 13:41
  • @MaTePe thanks for suggesting the link, first one resolved the issue: 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 Dec 14 '16 at 13:50
  • Maybe it was an known issue, resolved later. See [link1](https://issues.jenkins-ci.org/browse/JENKINS-34571), [link2](https://github.com/jan-molak/jenkins-build-monitor-plugin/issues/215), [link3](https://issues.jenkins-ci.org/browse/JENKINS-12875) – Sajib Khan Dec 14 '16 at 13:58
  • I am successfully using: curl -X POST http://username:secret@10.0.1.58/job/projectname/build with Jenkins 2.14. As my secret I am using an api token. You can generate this underneath the credentials section when you are logged in. You can also just try using your regular password. I think that would work too. – Venkata.Mutyala Dec 14 '16 at 15:22

1 Answers1

0

The first issue is below to capture the CRUMB:

CRUMB=$(curl -s 'git:git@localhost:8080/crumbIssuer/api/xml?xpath=concat(//…‌​) 

Then:

curl -X POST -H $CRUMB -u git:git localhost:8080/job/testjob/build
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
simplysifar
  • 11
  • 1
  • 5