Look at the syntax you're using.
variable=secretVar
You are creating an environment variable with the literal value secretVar
Then you try to execute the value of the variable $variable
with $($variable)
. So it tries to run the command secretVar
, which obviously doesn't exist, and you get an error message.
The syntax you're looking for is
variable=$(secretVar)
just like you used in the first echo
command in the script.
If you don't want to run the variable value as a command, the syntax would be $variable
, not $($variable)
$variable
is the syntax for a Bash environment variable.
$(variable)
is the syntax for referencing Azure DevOps variables.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…