I have a fairly simple pipeline where subproject_test
is not a secret, but openshift_token_test
is a secret.
steps:
- bash: |
echo "##vso[task.setvariable variable=project]$(subproject_test)"
echo "##vso[task.setvariable variable=openshift_token;issecret=true]$(openshift_token_test)"
displayName: Set test branch variables
- bash: |
echo ${PROJECT}
echo ${#OPENSHIFT_TOKEN}
displayName: Show vars
the output of Show vars
always shows 0 as length of OPENSHIFT_TOKEN
variable, while PROJECT
variable shown correctly. I did try adding env
and mapping secret to it - did not change anything.
CodePudding user response:
Resolved with using $(OPENSHIFT_TOKEN)
instead of ${OPENSHIFT_TOKEN}
CodePudding user response:
For people who meet the similar question to refer to.
This situation is totally expected.
Why this happens?
The usage is not correct.
${variable} is a usage of bash script, it is as same as $variable in bash. {} is just a disambiguation mechanism in bash, and it is not a variable usage in DevOps pipeline.
Official document clearly clarify why in this situation nothing will be put in:
It is the example, it also describe how to use the output variable correctly in same job:
How to use the output variables correctly in every situation: