Question

So I have a Jenkins Job which kicks off other jobs to run test scripts in a particular environment after code has been pushed to that environment (Example: Code is pushed to QA, Test Project is built, and then all QA tests run using "10 separate" test jobs).

This works great for the most part, however, there are times when I get "too many tests running" because people will perform lots of builds to a particular environment and that means I have multiple versions of the same tests running.

I would like to make it such that when a job runs and finishes, if its down stream jobs are currently running, they are stopped and then started again (I want the tests to run on the most recent build instead of having 2 test jobs being run on 2 different builds).

Does anyone know of a good way to do this? Or is there a plugin someone can recommend?

Was it helpful?

Solution

What I can recommend is that you add a batch file containing a HTTP request to cancel the last build of the job in question and then trigger the job in the next step. I think the URL below should help.

So in PostBuild step of JOB-A add a condition(single-and) step to check if the JOB-A successeded then

Execute a batch command to CANCEL JOB-B

AND

Kick off JOB-B again

Thsi should do the trick. (replace the HUDSON_URL)

HUDSON_URL/job/JOBNAME/lastBuild/stop

obviously if you may need to consider authentications if Jenkins requires a login.

Also i would say maybe in JOB-B you might want to set to block if upsteam project is building so it waits for the upstream job if its not running yet.

another reference here:

Hope this helped.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top