How to pass parameters between jobs - quick question

6,468 views
Skip to first unread message

zw

unread,
Jan 11, 2013, 2:49:38 PM1/11/13
to jenkins...@googlegroups.com
Hi All

We have job A to kick off Job B
Job A uses in build section execute shell to get a svn revision number and sets SVN_REVISION. 
(We understand that there's the option to use "This build is parameterized" String Parameter and set SVN_REVISION value as HEAD, but we have our reasons to not use that)
echo ${SVN_REVISION_NUM}
export SVN_REVISION=${SVN_REVISION_NUM}
echo ${SVN_REVISION}

output
+ SVN_REVISION_NUM=47337
:
+ echo 47337
47337
+ export SVN_REVISION=47337
+ SVN_REVISION=47337

In Post-build Actions section
we have Trigger parameterized build on other projects, and predefined parameter set to SVN_REVISION=${SVN_REVISION_NUM}

But in Job B console, it dosent see the revision number and Job B's SCM could retrieve the revision number
Location 'https://jobBhost.com/svn/src@${SVN_REVISION_NUM}' does not exist

What did we do wrong ?

Thanks

Stanley, Jason

unread,
Jan 11, 2013, 3:05:07 PM1/11/13
to jenkins...@googlegroups.com

I ran into this very same problem.

 

It appears (at least with my experience) the only variables passed from Job A -> Job B are the variables predefined by Jenkins.

 

To work around the issue,  in my build shell for Job A, I wrote the variable=value into a file and used the “Parameters from properties file”  Parameter in the “Trigger parameterized build on other projects” when running Job B.

 

Jason

William Soula

unread,
Jan 11, 2013, 3:41:56 PM1/11/13
to jenkins...@googlegroups.com
I think job B would see SVN_REVISION not SVN_REVISION_NUMBER because you are setting SVN_REVISION in the post-build section.  We use the "triggger/call builds on other projects" for the build step and it works perfectly fine to call job B from job A and echo the predefined parameters passed to it.  We use this to have a general deploy job that takes the server and instance as parameters from the more specific deploy job i.e. deploy_test calls deploy_web and passes the test server and instance as a parameter and this all works correctly.

Will

John Vacz

unread,
Jan 12, 2013, 3:31:20 AM1/12/13
to jenkins...@googlegroups.com

We also ended up generally saving all metadata (system/environment variables, jenkins parameters, and build properties etc) into properties file and archieve them. This approach simplifies/works around many problems we had. Now every build has its metadata archived, for downstream jobs or later references, we can get all necessary information from this one file, no extra parameters needed to be pass around. Furthermore, if anything went wrong, the metadata is very helpful for the investigation. I would also recommend this simple strategy.

Reply all
Reply to author
Forward
0 new messages