Reputation: 2960
I have two separate Jobs in Jenkins, but one job is only allowed to run if another jobs' last state was successful.
Please note: I do not want to automatically trigger the job; both jobs are triggered manually.
How can I achieve this?
note: I am using Jenkins declarative pipeline syntax.
Upvotes: 4
Views: 4770
Reputation: 1060
There are two ways, I can think of:
Fill up 'Kill the phase on'= 'Failure(stop the phase execution if the job is failed)' and 'Continuation condition to next phase when jobs statuses are' = 'Successful'. This will make sure, that next phase runs ONLY if the current phase passes.
NOTE: If you want to run more jobs in parallel under this phase, click on 'Add Job' but in your case, we want a sequential run for job1 and job2. Hence, we need two phases.
I hope this helps you.
Upvotes: 4
Reputation: 1401
Use Pre-requisite check build step and configure Upstream job to check the status
Refer the plugin here : https://wiki.jenkins.io/display/JENKINS/Prerequisite+build+step+plugin
If adding a plugin is an obstacle (eg restricted admin access), I suggest you log the details of status of upstream job into a file or in DB and fetch the same as a first step of downstream job.
Upvotes: 1