Conditional Build Steps

370 views
Skip to first unread message

Josh D

unread,
Jun 29, 2012, 3:49:44 PM6/29/12
to jenkins...@googlegroups.com
I have a parameterized job that has a number of dependencies that it copies in using parametrized copy artifacts build steps, e.g.: copy: sim-common-linux64/SIM_COMMON_REV=${SIM_COMMON_REV}.

If there isn't a build of sim-common-linux64 that matches the SIM_COMMON_REV, that step fails, as you would expect.  What I'd like to do is something like:

Execute copy artifacts->sim-common-linux64/SIM_COMMON_REV=${SIM_COMMON_REV}

If copy fails:
1. Trigger parameterized build on sim-common-linux64
2. Re-execute copy artifacts

I know I could get similar behavior by just issuing the parameterized build and then copying, but people here don't want to kick off jobs that aren't required.

Jan Seidel

unread,
Jul 3, 2012, 3:36:26 AM7/3/12
to jenkins...@googlegroups.com

Josh D

unread,
Jul 13, 2012, 1:44:28 PM7/13/12
to jenkins...@googlegroups.com
Unfortunately those wouldn't work.  Simply rescheduling the build wouldn't correct the problem that the external dependency doesn't exist.  Now yes, someone could detect the failure and manually execute a build on the dependency to rectify the problem before the rescheduled build takes place, but that doesn't rectify the problem.

I've been trying to get the following plugin to work: https://wiki.jenkins-ci.org/display/JENKINS/Conditional+BuildStep+Plugin

However, I cannot seem to get the conditional build step to run after a failed step.  For example, I defined a sequence:

1. copy artifacts->sim-common-linux64/SIM_COMMON_REV=${SIM_COMMON_REV}
2. conditional build step: Run? Current build status (worst: aborted best: unstable)
Steps to run if condition is built:
2a. Trigger/call builds on other projects: sim-common-linux64
2b. copy artifacts->sim-common-linux64/SIM_COMMON_REV=${SIM_COMMON_REV}

However, the conditional steps are never executed.  See the following output:
Started by user davidsj2
[EnvInject] - Loading node environment variables.
Building remotely on AST-Linux-x64-scts01 in workspace /disk01/BUILD/workspace/sast_product_linux64
[sast_product] $ hg showconfig paths.default
[sast_product] $ hg pull --rev default
[sast_product] $ hg update --clean --rev default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
[sast_product] $ hg log --rev . --template {node}
[sast_product] $ hg log --rev . --template {rev}
[sast_product] $ hg log --rev 8f947e56c1a6693687e8097fb50bba1626989ea6
[sast_product] $ hg log --template "<changeset node='{node}' author='{author|xmlescape}' rev='{rev}' date='{date}'><msg>{desc|xmlescape}</msg><added>{file_adds|stringify|xmlescape}</added><deleted>{file_dels|stringify|xmlescape}</deleted><files>{files|stringify|xmlescape}</files><parents>{parents}</parents></changeset>\n" --rev default:0 --follow --prune 8f947e56c1a6693687e8097fb50bba1626989ea6
Run condition [Current build status] enabling prebuild for step [BuilderChain]
Unable to find a build for artifact copy from: sim-common-linux64/SIM_COMMON_REV=zomg
Build step 'Copy artifacts from another project' marked build as failure
Archiving artifacts
Recording fingerprints
Notifying upstream projects of job completion
Finished: FAILURE

You can see that the run condition seems to be enabled. Then the intital copy fails, but the conditional build step never runs.

Jan Seidel

unread,
Jul 16, 2012, 5:18:06 PM7/16/12
to jenkins...@googlegroups.com
You are right,

the condition is met but your copy artifact plugin fails. The conditional build step works perfect.
I have seen this bug several time. In my occassion was the copier set to copy artifacts from the job that triggered that particular build instead of last successful build.
You should focus you on the artifact copier.

Take care
Jan

Josh D

unread,
Jul 17, 2012, 1:14:59 AM7/17/12
to jenkins...@googlegroups.com
Guess I'm not sure what side of the boat the hole was in.  I fiddled with it a couple hours before finding a new solution.  The way I set it up was to first attempt a parameterized artifact copy as an optional step.  Following that, I used the conditional build step plugin to check if the expected artifacts were copied and if not, kick off a parameterized build, wait, and then recopy.  Seems to be working well so far.
Reply all
Reply to author
Forward
0 new messages