Search code examples
azureazure-devopspackageuniversalartifacts

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). I assumed that the Azure command-line tools on the Azure DevOps virtual machines would have the latest Azure extensions installed. I was wrong.

My Python script invokes commands such as az artifacts universal download and az artifacts universal publish. This works great on my 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://learn.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'.

Solution

  • ERROR: az: 'artifacts' is not in the 'az' command group. See 'az --help'.

    You need to install Azure DevOps Extension first then use the az artifacts command. Please refer to Azure DevOps CLI in Azure Pipeline YAML for more information.

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

    Please add this to your yaml and try again. Hope this would work.