Reputation: 41498
I have a project (p1
) that is built nightly. Every Tuesday, I want to have a second project (p2
) built, but only on successful completion of p1
. p2
relies on successful build of p1
so p2
must not be triggered to run if that days' p1
fails.
The only way I can think of doing this is to create two identical p1 jobs p1a
and p1b
:
p1a
runs every day except tuesdayp1b
runs on tuesday, when finished successfully, triggers p2
This is a bit a mess however, as it creates multiple versions of p1
to maintain, with their own build history, etc...
Anyone know a better way to accomplish this?
Upvotes: 4
Views: 6192
Reputation: 41498
I found a fairly recent plugin, BuildResultTrigger Plugin. It allows conditional builds on multiple success of other jobs. It also allows for scheduling, so it can be set to poll the other jobs for successful condition: https://wiki.jenkins-ci.org/display/JENKINS/BuildResultTrigger+Plugin
The one draw back is it's can't be 'triggered' by another job, but only by scheduled polling.
Upvotes: 0
Reputation: 27505
You can use an Exclusion plugin.
p1
job should be on a nightly schedule to start earlier than p2
jobp1
job should be on a Tuesday-only schedule to start slightly later than p1
This way, on Tuesdays, when p2
runs, the "resource" will already be in-use by p1
. I haven't actually used this plugin, so not sure if it will cause p2
to wait or fail, but if the later is true, you can configure p2
to retry failed builds with something like this plugin
Alternatively, the Conditional Build Step plugin can be used.
p1
configure a Conditional Build Step after the building step (so if the building step fails, it never executes.p2
Upvotes: 3
Reputation: 893
There's a stack overflow question on Conditional Post build steps which might be of interest. In particular the post about the conditional post build plugin
Perhaps using that plugin and getting the current day of the week using a custom script and verify it's tuesday would solve your problem
Upvotes: 1
Reputation: 5174
You could set the starting time of both projects to the same (p2 a minute later or so).
Then you could define a lock (throttle concurrent build plugin or locks and latches) to allow only one of your jobs to run concurrently.
Alternatively, you could indeed create two jobs using the jobDSL plugin or something similar.
Upvotes: 0