Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 229 Vote(s) - 3.44 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How are environment variables used in Jenkins with Windows Batch Command?

#1
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

Reply

#2
In windows you should use `%WORKSPACE%`.
Reply

#3
I should this On Windows, environment variable expansion is %BUILD_NUMBER%
Reply

#4
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 WORKSPACE

echo %WORKSPACE%

If you need the value at execution time, then you need to use delayed expansion `!WORKSPACE!`. Delayed expansion is not normally enabled by default. Use `SETLOCAL EnableDelayedExpansion` to 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.

setlocal enableDelayedExpansion
set WORKSPACE=BEFORE
(
set WORKSPACE=AFTER
echo Normal Expansion = %WORKSPACE%
echo Delayed Expansion = !WORKSPACE!
)

The output of the above is

Normal Expansion = BEFORE
Delayed Expansion = AFTER

Use `HELP SET` or `SET /?` 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.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through