Build Triggers
So far we have been triggering the build using 2 ways:
- Manually
- By setting up a downstream job(which has an automatic trigger)
Let’s trigger the build remotely
The url created to trigger the job will be as below:
http://18.216.155.253:8080/job/projectname/build?token=alphatoken
Let’s hit the url and see the result
But there is one major issue in this. Here we have used the same browser, which was having our credentials saved for jenkins. If we try to trigger it from some remote laptop, it will ask for our jenkins credentials.
So as to tackle this scenario we will generate a token for admins user.
admin:xxxxxxx<token>
Next step is to Generate a Crumb
Execute the below command now:
wget -q --auth-no-challenge --user admin --password admin123 --output-document - 'http://18.216.155.253:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'
Now we have 3 details:
- The url created
- The API token generated
- Jenkins Crumb
Now we will use all these 3 things in a curl command to execute the build job from anywhere.
curl -I -X POST http://username:APIToken @Jenkins_IP:8080/job/Job_Name/build?token=TOKENNAME -H "Jenkins-Crumb:CRUMB"
Till now we have seen 3 ways to trigger the job. Let’s see another one.