setNextBuildNumber from upstream job

25 views
Skip to first unread message

Ewelina Wilkosz

unread,
Apr 18, 2018, 5:12:45 AM4/18/18
to Jenkins Users
I have an upstream job that passes COPY_FROM_BUILD parameter containing the number of upstream job build (dummy name, but good enough for developers to understand what's happening...)
In downstream job I tried to use

nextBuildNumber($COPY_FROM_BUILD)

and when creating the job my seed job complains

ERROR: (seed_leia.groovy, line 224) No such property: $COPY_FROM_BUILD for class: javaposse.jobdsl.dsl.helpers.properties.PropertiesContext

Either I'm doing something really stupid or nextBuildNumber won't work with upstream parameter... any idea anyone?
Build name setter won't be a good enough solution since I'm passing build namber, not name, to another tool I can't rally change :/

Victor Martinez

unread,
Apr 23, 2018, 4:39:18 AM4/23/18
to Jenkins Users

IIUC, there are two different points here:

1) Variable interpolation.

It looks like $COPY_FROM_BUILD is not interpolated unless it's double quoted: 

nextBuildNumber("$COPY_FROM_BUILD")

NOTE: that particular variable might be declared somehow, see below

2) Upstream parameter.

Off the top of my head: 

It might depends on how the upstream job triggers the downstream job.

a) If it's using the build step then you might create a new parameter to be used only when the upstream pipeline triggered the downstream job which will use the parameters accordingly.
b) Using the feature property 'hudson.model.ParametersAction.keepUndefinedParameters' . (described: https://wiki.jenkins.io/display/JENKINS/Features+controlled+by+system+properties) then you won't need to declare the parameter in the downstream job. Although, it  might be unsafe as explained
c) Other way, it might be using the archive and copyArtifact step and then readFile step
d) I'm pretty sure there are other ways that someone else could help with. :)

Cheers
Reply all
Reply to author
Forward
0 new messages