ranjjose
ranjjose

Reputation: 2148

Not able to access custom parameters passed to the jenkins build script

I want to add some parameters from the web hooks into the mail sent from the Jenkins. I tried solutions provided in StackOverflow and elsewhere. No success yet.

I have the following in place:

  1. Checked This is a parameterized build
  2. The build script looks like http://JENKINS_URL/job/android02/buildWithParameters?token=<My Token>&PARAM=<My Custom Params>
  3. In the mail content, I try to access the custom parameters by ${PARAM}, $PARAM. enter image description here In the mail, however, I'm not getting the values I'm setting. If I set default values for PARAM, it is correctly displayed in the mail I receive. I tried http://JENKINS_URL/job/android02/build?token=<My Token>&PARAM=<My Custom Params> URL as well thinking just in case if it works. The mail is sent as Editable email Notification config.

Basically, everything is working except that I'm not able to access the custom parameters I have passed via Trigger builds remotely option.

Edit1: If I keep a default value, say, test for the parameter, PARAM, in the mail received, I can see test displayed. But I need to get the value I'm passing in the build script.

Upvotes: 1

Views: 1269

Answers (1)

Jon S
Jon S

Reputation: 16346

From the "tool tip" that you get when you click on the question mark next to "":

${ENV,var="VARIABLENAME"}

Expands to an environment variable (specified here as VARIABLENAME) from the build environment. Note that this does not include any variables set by the build scripts themselves, only those set by Jenkins and other plugins.

So, use ${ENV,var="PARAM"}.

enter image description here

Upvotes: 1

Related Questions