简体   繁体   English

Azure DevOps 管道导致 az 登录失败

[英]az login fails wih Azure DevOps Pipelines

Since Today all our build pipelines on Azure Devops fail, when trying to execute the follwoing command:由于今天我们在 Azure Devops 上的所有构建管道都失败了,当尝试执行以下命令时:

az acr helm push ...

The pipeline fails with following error:管道失败并出现以下错误:

ERROR: Please run 'az login' to setup account.

We are running on Microsoft hosted agents using Hosted Ubuntu 1604 .我们使用Hosted Ubuntu 1604在 Microsoft 托管代理上运行。
Checking the latest commits for the Ubuntu image shows, that there has been a version update from 2.0.52 to 2.0.55 of the azure cli tool.检查 Ubuntu 映像的最新提交显示,azure cli 工具的版本已从2.0.52更新到2.0.55

https://github.com/Microsoft/azure-pipelines-image-generation/commit/56c54c965019c4f7456cd9af572a443df9d5d78c#diff-f87405c9dd43f633a04dd078666d61af https://github.com/Microsoft/azure-pipelines-image-generation/commit/56c54c965019c4f7456cd9af572a443df9d5d78c#diff-f87405c9dd43f633a04dd078666d61af

Maybe this version update introduced the problem.也许这个版本更新引入了这个问题。 Just guessing.只是猜测。

Can anyone help please?有人可以帮忙吗?

I added the following to my pipeline to downgrade azure-cli a version, and my pipeline is now passing我在我的管道中添加了以下内容以降级 azure-cli 一个版本,我的管道现在正在通过

- bash: sudo apt-get install -y --allow-downgrades azure-cli=2.0.54-1~xenial
  displayName: 'downgrade azure-cli'

The issue has been raised with the azure-cli tool team.该问题已向 azure-cli 工具团队提出。

To proceed now you can follow any of the two workarounds as of now:要立即继续,您可以按照以下两种解决方法中的任何一种操作:

  • Use Az CLI task instead of Bash script to run az commands.使用 Az CLI 任务而不是 Bash 脚本来运行 az 命令。
  • Use Hosted VS2017 agent to run az commands because this agent has 2.0.52 version of az-cli tool which runs this command successfully (as against Hosted Ubuntu 1604 which has az-cli v2.0.55)使用托管 VS2017 代理运行 az 命令,因为该代理具有 2.0.52 版本的 az-cli 工具,可以成功运行此命令(与具有 az-cli v2.0.55 的托管 Ubuntu 1604 相比)

Update to @Andy answer since this command is no longer valid .更新到 @Andy 答案,因为此命令不再有效

When working with Azure DevOps Hosted agents, Some software is installed on the machine automatically.使用 Azure DevOps 托管代理时,某些软件会自动安装在计算机上。 The full list can be found here Ubuntu.完整列表可以在这里找到 Ubuntu。

One of the Softwares is Azure CLI:Latest .其中一种软件是Azure CLI:Latest Therefore, in case you want to downgrade you need to install a new version.The following command is how i managed to install new version (Bash):因此,如果您想降级,则需要安装新版本。以下命令是我设法安装新版本 (Bash) 的方法:

sudo apt install -y --allow-downgrades azure-cli=%AZ VERSION%-1~bionic

Usage:用法:

sudo apt install -y --allow-downgrades azure-cli=2.2.0-1~bionic

What does the trick is to use ~bionic after specifying the version you want to install.诀窍是在指定要安装的版本后使用~bionic

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM