How do i pass a build number to a downstream job for jobs that are part of a Build Pipeline

2,284 views
Skip to first unread message

Eric Wood

unread,
Jul 30, 2014, 9:16:15 AM7/30/14
to Jenkinsci-users
I use the build pipeline to manage a series of related jobs (downstream).  I want to be able to pass the build number from the upstream job to be used in the downstream jobs as the build number there.  How is this best accomplished.

Thanks, Eric

Chris Williams

unread,
Jul 30, 2014, 10:20:06 AM7/30/14
to jenkins...@googlegroups.com
Hi,
I usually  add a "Predefined parameter" something like MYBUILD_NUMBER=${BUILD_NUMBER}  and use that environment variable (Parameter) in the next build step.....

Chris


On 30 July 2014 15:13, Eric Wood <eric...@rocketmail.com> wrote:
I use the build pipeline to manage a series of related jobs (downstream).  I want to be able to pass the build number from the upstream job to be used in the downstream jobs as the build number there.  How is this best accomplished.

Thanks, Eric

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Wood

unread,
Jul 31, 2014, 7:39:11 AM7/31/14
to jenkins...@googlegroups.com
Chris:

Thanks for the reply. Not sure i fully understood the steps. Can you elaborate? Where do i set a Predefined parameter and are you saying that once the variable is predefined I can merely reference the variable using the ${MYBUILD_NUMBER} in the downstream job?

Chris_W...@dell.com

unread,
Jul 31, 2014, 11:14:13 AM7/31/14
to jenkins...@googlegroups.com

Some of our jobs use the following script in a build step to set the build number of the downstream jobs:

 

echo **** Keep build numbers in pipeline consistent ******

"C:\Program Files (x86)\Curl\curl.exe" -d "nextBuildNumber=%BUILD_NUMBER%" http://user:password@localhost:8080/job/DOWNSTREAM_JOB1/nextbuildnumber/submit

"C:\Program Files (x86)\Curl\curl.exe" -d "nextBuildNumber=%BUILD_NUMBER%" http://user:password@localhost:8080/job/DOWNSTREAM_JOB2/nextbuildnumber/submit

 

 

This uses the nextbuildnumber plugin.

 

[a different] Chris Williams

Dell | PG Release Engineering

Ng, Jeff

unread,
Jul 31, 2014, 2:08:07 PM7/31/14
to jenkins...@googlegroups.com

I use the ParameterizedTriggerPlugin to pass various properties, including build name/number, to downstream jobs.  In the upstream job, I have a build step to write the properties to a properties file in the workspace.  Then, using the plugin’s “Trigger parameterized build on other projects” task, I specify the downstream project and specify the properties file in the “Parameters from properties file” field.

 

Then, in the downstream job configuration, select “This build is parameterized” and create a “string parameter” for each of the desired properties from the properties file you created in the upstream job.

 

-Jeff Ng

Reply all
Reply to author
Forward
0 new messages