Hi,


Are you using a recent version of Jenkins and the parameterized plugin?



I suspect the problem is that you are defining $PREFIX locally on the machine, 
and then trying to reference it via a Jenkins job configuration. When I’ve 
encountered that situation I’ve worked around it by writing the value to a 
.properties file and then passing that file to the downstream job (using the 
‘Parameters from a properties file’) option.



As for the other environment variables, passing $JOB_NAME and $BUILD_NUMBER 
work just fine for me.



Upstream job (entitled “zTest Parameters”) configuration:



[cid:image003.png@01CFF915.BEF7BD10]



Downstream job’s /parameters page:



[cid:image004.png@01CFF915.BEF7BD10]



Terry





-----Original Message-----
From: jenkinsci-users@googlegroups.com 
[mailto:jenkinsci-users@googlegroups.com] On Behalf Of Adam Mercer
Sent: Wednesday, November 05, 2014 4:14 PM
To: jenkinsci-users@googlegroups.com
Subject: Passing environment variables using the parameterized trigger plugin



Hi



According to the documentation for the Parameterized Trigger plugin, 
specifically for 'Predefined parameters":



"""

KEY=value pairs, one per line (Java properties file format).

Backslashes are used for escaping, so use "\\" for a single backslash.



Current build parameters and/or environment variables can be used in

form: ${PARAM} or $PARAM

"""



I'm trying to use this to pass the contents of an environment variable to the 
next job in line, but it is not passed. In Job1 is essentially the execution of 
the following script:



#!/bin/bash

# display job parameters

echo "JOB_NAME = $JOB_NAME"

echo "BUILD_NUMBER = $BUILD_NUMBER"

export PREFIX=/build/$JOB_NAME/$BUILD_NUMBER/lal

echo "Installing in $PREFIX"



And in the "Predetermined parameters" section I have:



LAL_JOB_NAME=$JOB_NAME

LAL_BUILD_NUMBER=$BUILD_NUMBER

LAL_PREFIX=$PREFIX



When Job1 completes successfully and outputs:



JOB_NAME = LALSuite/LAL/label=sl6

BUILD_NUMBER = 6

Installing in /build/LALSuite/LAL/label=sl6/6/lal

Finished: SUCCESS



It then triggers Job2 which is essentially the following script:



#!/bin/bash

# show parameters

echo "LAL_JOB_NAME = $LAL_JOB_NAME"

echo "LAL_BUILD_NUMBER = $LAL_BUILD_NUMBER"

echo "LAL_PREFIX = $LAL_PREFIX"



When executed Job2 displays:



LAL_JOB_NAME = LALSuite/LAL

LAL_BUILD_NUMBER = 6

LAL_PREFIX = ${PREFIX}



So the contents of JOB_NAME isn't being passed correctly the value of the 
PREFIX environment variable is being completely ignored.



How can I pass the contents of an environment variable to another job using the 
parameterized trigger plugin? Or is there another plugin that would be better 
in this situation?



Cheers



Adam



--

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-users+unsubscr...@googlegroups.com<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.

For more options, visit https://groups.google.com/d/optout.

-- 
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-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to