Jenkins Parameterized Remote Trigger Plugin

29 / Jun / 2015 by Gunjan Sawhney 6 comments

At times you encounter a use case where you need to run a Jenkins job remotely from another Jenkins instance. Well, there is a way to achieve this by using Parameterized Remote Trigger plugin.

Let’s see how we can trigger parameterized or non-parameterized jobs on remote Jenkins server from another Jenkins server.

Demonstration

Lets say we have two Jenkins server namely JenkinsOne and JenkinsTwo and we have a job name “TEST” on JenkinsTwo which we want to trigger from JenkinsOne.

To achieve the above stated task, we need to download Parameterized Remote Trigger Plugin on JenkinsOne. You can do that by clicking on Manage Jenkins option and then choosing Manage Plugins, wherein you can search and download the desired plugin.

Our JenkinsTwo server has password based access. So to trigger a job on it, first we need to log in to the server and then build the job. For this to happen from a remote server, we need to provide credentials to it. So before triggering a remote build on JenkinsOne, set the credentials by following the below mentioned steps.

Step 1:
Go to Manage Credentials option after choosing Manage Jenkins option on your console.

2

Step 2:
After that, choose add domain option. As our JenkinsTwo is a remote server so we need to specify its host name here.

3

Step 3:
After this specify the credentials so that we can log into JenkinsTwo. Since on the JenkinsTwo server we have password based authentication, we have to choose “Username with password” option as shown in the screenshot below.

4

Specify scope, username and password and save the changes.

5

6

Step 4:
Now go to Configure System option after selecting Manage Jenkins option.  Under Parameterized Remote Trigger Configuration, click on Add.

8

Step 5:
As soon as we click on Add, the Display name field will automatically show already added remote Jenkins server which is JenkinsTwo. After checking the “Use the credentials Plugin” option, we can see the already provided credentials. Now to access the server, we need to provide JenkinsTwo address and port number.

9

Step 6:
Now make a new job in JenkinsOne. Here we are making this as a parameterized job, since our “TEST” job on JenkinsTwo is parameterized.

10

Step 7:
Now under the Build section, choose “Trigger a remotely parameterized job” option in the drop down menu of “Add build step” option as shown below.

11

Step 8:
After doing that, we can choose our remote Jenkins server in “Select a remote host” field.

12

Step 9:
Type the name of the job which you want to build on remote jenkins server i.e. “TEST” job on JenkinsTwo server in our case. Specify the parameter i.e “NAME” required by the “TEST” job. Also, we need to use the value defined here in “name” parameter as shown below. Save your configuration changes.

13

Step 10:
The final step remaining is to Build the job.

14

Step 11:
After building the job, in the Console Output we can see that the job has been remotely built if all the configuration changes have been made correctly.

15

Step 12:
On our remote server  “JenkinsTwo”, if we can log in, we can verify that our job has been executed with the parameter’s value that was provided on JenkinsOne server and by the same user whose credentials we provided in the  initial steps.

16

FOUND THIS USEFUL? SHARE IT

comments (6)

  1. Santhosh Hari

    Thats a nice explanation. Can you explain how to pass file to a remote job.
    I tried and it doesn’t work using Load external files field

    Reply
  2. Sabrina

    Hi, I was wondering if you had ever run into the error: “Server returned HTTP response code: 403 for URL: my.server:8080//job……..” My JenkinsOne does not seem to be able to access JenkinsTwo or is having trouble communicating. All of my credentials are correct. Do you have any troubleshooting recommendations?

    Reply
  3. Basma Shahadat

    Does this plugin work with Jenkins 2.0? Getting the following error while validating the remote host ..
    Address looks good, but we were not able to connect to it

    Reply
  4. Le Vu

    Thank you the information. It is very helpful for me. For the remote job on the JenkinsTwo server, I want to pass in a file parameter to it. For Jenkins Parameterized Trigger Plugin, there is a way to pass a file to the child project. For Jenkins Parameterized Remote Trigger Plugin, I want to pass file to the remote job. How do I do that? Thank you

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *