Reputation: 1305
I am trying to specify a value for a Jenkins environment variable (as created on the Manage Jenkins -> Configure System screen, under the heading "Global properties") which contains a space. I want to use this environment variable in an Execute Shell build step. The option that I need to appear in the command line in the build step is:
--platform="Windows 7"
The syntax I am using on the command line is --platform=${VARIABLE_NAME}
No matter how I attempt to format it, Jenkins seems to reformat it so that it is treated as two values. I have tried:
The corresponding results, when output during the Execute Shell build step have been:
I have also tried changing my command line syntax to --platform='${VARIABLE_NAME}'
as well as '--platform=${VARIABLE_NAME}'
, but in each of those cases the ${VARIABLE_NAME}
is not resolved at all and just appears as ${VARIABLE_NAME}
on the resulting command.
I am hoping there is a way to make this work. Any suggestions are most appreciated.
Upvotes: 11
Views: 13643
Reputation: 9503
You should be able to use spaces without any special characters in the global properties section.
For example, I set a variable "THIS_VAL" to have the value "HAS SPACES".
My test build job was the following:
#!/bin/bash
set +v
echo ${THIS_VAL}
echo "${THIS_VAL}"
echo $THIS_VAL
and the output was
[workspace] $ /bin/bash /tmp/hudson8126983335734936805.sh
HAS SPACES
HAS SPACES
HAS SPACES
Finished: SUCCESS
I think what you need to do is use the following:
--platform="${VARIABLE_NAME}"
NOTE: Use double quotes, not single quotes. Using single quotes makes the stuff inside the quotes literal, meaning that any variables will be printed as is, not parsed into the actual value. Therefore '${VARIABLE_NAME}' will be printed as is, not parsed into "Windows 7".
EDIT: Based on @BobSilverberg comment below, use the following:
--platform="$VARIABLE_NAME"
Note: no curly brackets.
Upvotes: 10