Reputation: 29
I have two builds that are triggered periodically,
-first build runs every night
-second build runs every week
how do I trigger weekly build every week but only if the daily build of the day beforehand have passed successfully ?
Upvotes: 2
Views: 579
Reputation: 1745
To add to the good answer from Petr, if you have the "jq" command available to you, you can easily get the result
curl -u ${USERNAME}:${TOKEN} http://<jenkins_url>/job/<job_name>/lastCompletedBuild/api/json | jq '.result'
Returns "SUCCESS" if the previous job was successful
Upvotes: 2
Reputation: 480
From the weekly job, I would suggest checking the build status of the first job in a bash script step and continue or exit the job based on the first job build status. You can do that by doing curl
on that job, something like this:
curl -u ${USERNAME}:${TOKEN} http://<jenkins_url>/job/<job_name>/lastCompletedBuild/api/json
The ${USERNAME}:${TOKEN}
should be only needed if you are using authentication on your server. From the curl
response you can then grep
for the result
and continue with the logic - quit the job if the result is not success or whatever you need.
Upvotes: 2