Search code examples
jenkinstriggersjenkins-pluginsremote-server

Trigger a jenkins build when remote jenkins job has finished


I have jenkins installed on two different servers s1 (where I can see the status of the projects but where I can not modify nor add any item) and s2 where I have full control of Jenkins and of the server.

I have a project in Jenkins in s2 that I would like to execute when a specific build on s1 has finished (with success).

I know I could use the Parameterized Trigger Plugin in s1 and from there trigger a job in s2, but I will have to ask someone with the required permissions to do it for me.

I wonder if there is any way I can monitor the job in s1 (to which I have read access) from s2 and trigger my project when the build is successful. Can I do this?


Solution

  • The solution is to use the URLTrigger plugin.

    Please install this plugin on the s2 server.

    On your s2 job, choose the "[URLTrigger] - Poll with a URL" build trigger with some settings like below:

    enter image description here

    You can check the following status: lastBuild, lastStableBuild, lastSuccessfulBuild, lastFailedBuild, lastUnstableBuild, lastUnsuccessfulBuild, lastCompletedBuild.

    For each status, you can get the build number for example by adding /buildNumber.

    Example: .../lastSuccessfulBuild/buildNumber will return 4 (build #4)

    enter image description here

    The plugin will calculate a MD5 with this build number. Every hour, the triggerURL plugin will have a look to the URL. If the MD5 changes, it will trigger a build.

    It should do the job :)