Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a Jenkins build from outside of Jenkins?

Tags:

jenkins

People also ask

How do you call a Jenkins build from outside Jenkins?

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.

How can I call Jenkins remotely?

Create a remote Jenkins build trigger in three stepsCreate a Jenkins build job and enable the Trigger builds remotely checkbox. Provide an authentication token; This can be any text string of your choice. Invoke the Jenkins build URL to remotely trigger the build job.

How can I call Jenkins job from another Jenkins job?

Now just go to your source Jenkins job and Click Configure button. Under Build Section, Add Trigger a remote parameterized job as a build step. Then select the Destination Jenkins name that we just added, give the job name that you want to trigger at destination Jenkins(here it is test ) and parameters.

Can Jenkins can be run from external Web server?

A Jenkins server available on the public Internet and configured with Git, Maven, Notification plugin, and Build Authorization Token Root plugin. You would also need the Admin privileges of the Jenkins server to install the plugins, if they are not already installed. Note: This tutorial is created using Jenkins ver.


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.


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.


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'