Azure-pipelines-tasks: Add option to not run az clear at end of Azure CLI VSTS Task

Created on 9 Jan 2018  路  6Comments  路  Source: microsoft/azure-pipelines-tasks

We are using the Azure CLI task to grab an access token to be used in a subsequent task. However, it looks like the Azure CLI step is executing the az clear command which clears out the token at the end of that task. We were able to get around this by creating two Powershell tasks to issue the az login command as a Service Principal and a second to run the az clear command. We would prefer to use the Azure CLI task as it runs as a service endpoint which obscures the credentials. Is there an option to prevent the az clear from running?

Release enhancement

Most helpful comment

We can consider adding it to the advanced section. Adding @RoopeshNair for his opinion here.
However, as a work-around after you have generated the token, consider saving it in secret variable. Will this approach variable. You can use echo "##vso[task.setvariable <>=<>;issecret=true;]" to do it.

All 6 comments

We can consider adding it to the advanced section. Adding @RoopeshNair for his opinion here.
However, as a work-around after you have generated the token, consider saving it in secret variable. Will this approach variable. You can use echo "##vso[task.setvariable <>=<>;issecret=true;]" to do it.

Using task output variables is the right approach. Let us know if it isn't working for you

@sachinma @RoopeshNair how would you then use this variable in subsequent steps?

Any variable set with ##vso[task.setvariable ..] will be available to next set of tasks same as any other build/release variable.

secret variables have to be explicitly passed as an argument to the next step.

so output a variable with the value az account get-access-token should suffice

Was this page helpful?
0 / 5 - 0 ratings