0
votes

I am trying to trigger a job present in jenkins hosted in openshift platform. I am trying to trigger the job through command line.

I tried the below:

curl -x post -u username:password https://myjenkins.com/job/myjob/build?delay=0sec

and this resulted in

Invalid password/token for user:

  1. I tried to use create a token in jenkins and supplied that too and no luck.

  2. I removed the user id and password from my curl command and that resulted in the error message No valid crumb was included in the request

  3. I then tried to do a wget to get a crumb. The command runs but does not return anything

./wget -q --auth-no-challenge --user username --password password --output-document - 'https://myjenkins/crumbIssuer/api/json'

  1. 'Options Enable proxy compatibility' and the 'Prevent Cross Site Request Forgery exploits' are checked in jenkins security configuration

Any help much appreciated.

1

1 Answers

0
votes

To trigger builds remotely, you need to create an authentication token too.

Once you have the authentication token, you can pass it as a parameter while making the request like job/myjob/build?token=<authentication-token>.

You can perform the operation using either username:password or username:apiToken.

$ curl -x post -u username:password http://myjenkins.com/job/myjob/build?token=wefiytgw...
$ curl -x post -u username:apiToken http://myjenkins.com/job/myjob/build?token=wefiytgw...

You can also take a look to this answer.