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:
I tried to use create a token in jenkins and supplied that too and no luck.
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
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'
Any help much appreciated.
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.