简体   繁体   English

从 Azure DevOps 管道 YAML 文件运行 `az artificats` 命令

[英]Running `az artificats` commands from Azure DevOps pipeline YAML file

In my Azure Pipelines YAML file, I'm using a Bash task to run a Python script that caches CocoaPods libraries on Azure Artifacts (Universal Packages).在我的 Azure Pipelines YAML 文件中,我使用 Bash 任务运行 Python 脚本,该脚本在 Azure Artifacts(通用包)上缓存 CocoaPods 库。 I assumed that the Azure command-line tools on the Azure DevOps virtual machines would have the latest Azure extensions installed.我假设 Azure DevOps 虚拟机上的 Azure 命令行工具会安装最新的 Azure 扩展。 I was wrong.我错了。

My Python script invokes commands such as az artifacts universal download and az artifacts universal publish .我的 Python 脚本调用诸如az artifacts universal downloadaz artifacts universal publish This works great on my Mac.这在我的 Mac 上效果很好。 Not so much on Microsofts VMs.在微软的虚拟机上没有那么多。

Any advice would be appreciated.任何意见,将不胜感激。

##[section]Starting: Bash
==============================================================================
Task         : Bash
Description  : Run a Bash script on macOS, Linux, or Windows
Version      : 3.159.3
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
==============================================================================
Generating script.
Script contents:
./cache_pods.py Debug
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /Users/runner/runners/2.160.1/work/_temp/d0fd889d-a201-42ac-aad6-45ee3eca0532.sh
ERROR: az: 'artifacts' is not in the 'az' command group. See 'az --help'.

ERROR: az: 'artifacts' is not in the 'az' command group.错误:az:'artifacts' 不在 'az' 命令组中。 See 'az --help'.参见“az --help”。

You need to install Azure DevOps Extension first then use the az artifacts command.需要先安装 Azure DevOps Extension,然后使用 az artifacts 命令。 Please refer to Azure DevOps CLI in Azure Pipeline YAML for more information.有关详细信息,请参阅Azure Pipeline YAML 中的 Azure DevOps CLI

steps:
- script: az extension add -n azure-devops
  displayName: 'Install Azure DevOps Extension'

Please add this to your yaml and try again.请将此添加到您的 yaml 中,然后重试。 Hope this would work.希望这会奏效。

Get same issue After spending an hour get solution : Without extension, it can't work so try to follow below step:得到同样的问题花了一个小时得到解决方案:没有扩展,它无法工作,所以尝试按照以下步骤操作:

First try to hit the below command to find the extension首先尝试点击下面的命令来找到扩展名

az extension add --name azure-devops

and then check that extensions is available or not :然后检查扩展是否可用:

Eg.例如。 For Pipelines:对于管道:

az extension add --name azure-devops

And the run that command并运行该命令

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

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