Make Jenkins job B (Running on Jenkins Server X) dependent on Jenkins A (Running on Server Y)
Make Jenkins job B (Running on Jenkins Server X) dependent on Jenkins A (Running on Server Y)
I have two jobs running on two different Jenkins Server Machines.
Job A => Server Y (Development Server)
Job B => Server X (Testing Server)
Job B, runs every 15 minutes continuously 365 days. Now, when Job A runs then Job B fails, as Job A is the code deployment. So, ideally my Job B should hold and not run during the time of Job A run.
Can someone please help with either any plugin that can help achieve this or any script and how to configure it.
Just to put it in a simple way, both these jobs should not run concurrently
1 Answer
1
There are two options in your case:
Use Jenkins REST API to communicate between server X and server Y.
For example, as first build step of job B you can check if job A is in running state:
curl -X GET -i 'http://y-host:y-port/job/job-A-name/lastBuild/api/json'
There is building
property in the response, which can tell about current job status:
building
"building": false,
"displayName": "#22",
"duration": 127163,
"estimatedDuration": 123022,
// many more data...
If job A is running ("building": true
), then you can pause or abort your job B.
"building": true
And vice versa, you can check if the tests are running on server X before you start deployment on server Y.
Oh, I see, you have two Jenkins masters. In such case the only option is to use REST API. I updated my answer with some suggestions about how you can use it.
– Alexey Prudnikov
Aug 31 at 13:08
I will try this one and update with the results Alex. Thank you very much in advance.
– Khaja Mohammed
Aug 31 at 13:39
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
But does this work if i have the job on a different server am looking for? I see in the below screenshot from the image on the plugins site that we specify the job names, but i doubt if we can give job names on a different server? wiki.jenkins-ci.org/download/attachments/62063114/…
– Khaja Mohammed
Aug 31 at 12:16