`##vso[task.setvariable]` does not work as expected if `issecret=true`
See original GitHub issueAccording to https://github.com/Microsoft/vsts-tasks/blob/master/docs/authoring/commands.md, I should be able to call Write-Host ("##vso[task.setvariable variable=testvar;issecret=true;]testvalue")
in a Powershell build step and then call Write-Host "testvar: $Env:testvar"
in a subsequent Powershell build step, but it doesn’t seem like the variable was saved because the output is just testvar:
when I was expecting testvar: ********
.
If I remove issecret=true;
, it works as expected, but the value is not masked in the output.
Thank you.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
`##vso[task.setvariable]` does not work as expected if `issecret ...
Secret variables must be passed into tasks via inputs (i.e. text box). I'll clarify in the docs.
Read more >vso[task.setvariable does not pass the variable onto the next ...
I have a process variable setup in my VSTS build called currentDate. I then have a PowerShell script that sets that variable to...
Read more >Azure pipeline output variables task.setvariable is not ...
But I see that output variables using bash or script is not working in azure pipeline yml. I am using ubuntu agent. -...
Read more >Classic release and artifacts variables - Azure Pipelines
setvariable logging command. Note that the updated variable value is scoped to the job being executed, and does not flow across jobs or...
Read more >Gotchas when sharing variables with Azure DevOps stages ...
bash: echo "##vso[task.setvariable variable=secretValue3 ... immediately notice that our first var1 variable has been resolved as expected, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to use macro syntax in the input text boxes for secrets. Here is an example:
@jnoyola I use a powershell script that generates random characters (based on https://devblogs.microsoft.com/scripting/generate-random-letters-with-powershell/) At the end of the script I inject it into the pipeline via
The issecret means it doesn’t show up in logs. So, I don’t actually convert the random string to a secure string via the
ConvertTo-SecureString
but thanks to the issecret flag it stays hidden from logging.In your ARM template, define your parameter as securestring like I mentioned above.