I am new to Jenkins, and I\'m not sure if this is possible, but I would like to set up a web interface where somebody could click \"Start Job\" and this will tell Jenkins to
Install Generic Webhook Trigger plugin. Select generic webhook trigger in build trigger actions. Generate a random string and paste in token. Now your job can be triggered with a http request to the following url.
http://JENKINS_URL/generic-webhook-trigger/invoke?token=TOKEN_VALUE
replace your jenkins url and token value
curl -H POST http://USERNAME:PASSWORD@JENKINS_HOST:PORT/job/JOB_NAME/build?token=YOUR_TOKEN
Set YOUR_TOKEN
at job configuration -> build triggers -> Trigger builds remotely.
Here is a link to the documentation: Jenkins Remote Access API.
Check out the Submitting jobs section.
In your job configuration you setup a token and then create a POST
request to JENKINS_URL/job/JOBNAME/build?token=TOKEN
. That's probably the most basic usage.
Aha, I found it in the documentation. So simple:
http://YOURHOST/jenkins/job/PROJECTNAME/build
I needed to add parameters and I wanted to do it over https. It took me a while but the following worked for me:
curl --request POST --url 'https://HOST_NAME/job/JOB_NAME/buildWithParameters?token=TOKEN' --header 'cache-control: no-cache' --header 'content-type: application/x-www-form-urlencoded' --data 'name1=value1&name2=value2'
There is a good sample of using the above API from Python. The project is called Python Jenkins, and you may find it here: link