Search code examples
bashazureazure-devopsazure-cli

How to set up az cli concrete version in Azure DevOps


After last updates of Azure DevOps our pipelines stopped working.
I am using AZURE CLI tasks.
Investigation shows that az cli was updated to 2.2.0, but nothing was changed on our side.

/usr/bin/az --version
azure-cli                          2.2.0

And some az cli operations starts to print warnings.
Warnings by default are redirected in bash to error stream, so I end up with:

Error: The process '/bin/bash' failed because one or more lines were written to the STDERR stream

How to set up concrete version of az cli for my pipelines?
I want pipelines to be stable with Azure DevOps updates.


Solution

  • How to set up az cli concrete version in Azure DevOps

    To resolve the error, please try to run the task again with the option "Fail on Standard Error" unchecked:

    enter image description here

    Besides, I am afraid there is no such out of box way to set up concrete version of az cli. Neither can I install an old version in an agent that already has the latest version az cli, either through python commands or chocolate packages:

    python commands:

    pip install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge
    

    This command line only install the latest version of az cli. Since I do not have the old version url, I could not test if it works with python command to install the old version az ci when there is a latest version already installed.

    Then I test it by the chocolatey package:

    https://chocolatey.org/packages/azure-cli/2.1.0#individual

    choco install azure-cli --version=2.1.0 --force
    

    But, this installation command still fails due to the existence of a latest version package.

    Check this thread for some more details.

    Alternatively, you could set up private agent to build your project, and install the old version azure-cli by the choco package.

    Hope this helps.