I’m trying to use Jenkins (Global) environment variables in my xcopy script.
${WORKSPACE} doesn't work
"${WORKSPACE}" doesn't work
'${WORKSPACE}' doesn't work
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I know nothing about Jenkins, but it looks like you are trying to access environment variables using some form of unix syntax – that won’t work.
If the name of the variable is WORKSPACE, then the value is expanded in Windows batch using
%WORKSPACE%. That form of expansion is performed at parse time. For example, this will print to screen the value of WORKSPACEIf you need the value at execution time, then you need to use delayed expansion
!WORKSPACE!. Delayed expansion is not normally enabled by default. UseSETLOCAL EnableDelayedExpansionto enable it. Delayed expansion is often needed because blocks of code within parentheses and/or multiple commands concatenated by&,&&, or||are parsed all at once, so a value assigned within the block cannot be read later within the same block unless you use delayed expansion.The output of the above is
Use
HELP SETorSET /?from the command line to get more information about Windows environment variables and the various expansion options. For example, it explains how to do search/replace and substring operations.