Calling a Jenkins build from outside of Jenkins?

Solution 1:

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.

Solution 2:

Jenkins has support for parameterized build as well.

So, if you want to pass parameters for configurable build generation, you can pass them by posting it while invoking Jenkins build request with http://YOURHOST/jenkins/job/PROJECTNAME/buildWithParameters.

Solution 3:

Aha, I found it in the documentation. So simple:

http://YOURHOST/jenkins/job/PROJECTNAME/build

Solution 4:

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'