Home > Back-end >  Az Devops Commands Failing in Azure Pipelines (Classic)
Az Devops Commands Failing in Azure Pipelines (Classic)

Time:10-06

I am at a loss as to why I cannot run a basic az devops command in an Azure Pipeline using the Classic template.

So basically, I have two Powershell tasks defined for my Classic pipeline and these are:

enter image description here

Task 1: Login to my Azure DevOps organisation using the following commands:

$mytoken = "My_PersonalAccessToken"
echo $mytoken "|" az devops login --organization https://dev.azure.com/OrganisationName

Task 2: List My Azure DevOps Projects

az devops project list

Task 1 works perfectly and login is confirmed as successful.

Task 2 however fails and displays the below error in the pipeline output:

 Before you can run Azure DevOps commands, you need to run the login command(az login if using AAD/MSA identity else az devops login if using PAT token) to setup credentials.  Please see https://aka.ms/azure-devops-cli-auth for more information.

enter image description here

What could I be doing wrong? Would really appreciate some help, although I must emphasise again that my pipeline uses the Classic template and any proposed solution must be tailored for that.

Mind you, when I run these very same commands in my Powershell ISE editor, both run perfectly and I get all my Azure DevOps projects listed.

CodePudding user response:

Maybe there is a product issue recently, as the Azure CLI should work, it worked for me last month, see enter image description here

CodePudding user response:

I see that piping PAT on StdIn to az devops login is failing. However, an even better approach IMHO would be to set the AZURE_DEVOPS_EXT_PAT environment variable, and not use az devops login at all. :)

Pipeline variables:

enter image description here

Tasks:

enter image description here

Check Sign in with a personal access token (PAT) for more details.

  • Related