Create and manage Azure Pipelines from the command line

George Verghese

We recently introduced a unified YAML experience in Azure Pipelines where you can configure pipelines to do CI, CD or CI and CD together. Over the past few months we have been building capability to manage YAML backed pipelines from the command line to cater to developers who prefer working from the command line interface or require commands to automate set up and management. We are excited to announce the availability of az pipelines command in the Azure DevOps extension for developers who want to create and manage YAML backed Azure Pipelines from the CLI. The az pipelines command group allows you to create, delete, list, run, show and update a pipeline, enabling you to manage pipelines effectively from the command line.

Create an Azure Pipeline from the command line

Interacting from the command line can get challenging by having to remember various parameters and keying it in properly. To make things simple, we have crafted the az pipelines create command by letting developers go from a Git repo to a pipeline through an easy to use interactive flow, eliminating any need to remember a bunch of parameters.
1. To start, you need the Azure CLI with the Azure DevOps extension installed. Have a look at the Azure DevOps CLI – Get Started documentation for details.
2. Clone your Git repository and navigate to the repo directory.
3. Run az pipelines create:
az pipelines create --name "Contoso.CI"
4. Follow the steps to set up the pipeline.

Check out the documentation for more details.

You can also automate the entire pipeline creation process by providing a reference to a YAML file inside your repository. Picking up from the example above, imagine you had the completed YAML available in the repository; you can create the pipeline by simply running the command:
az pipelines create --name "Contoso.CI" --yml-path /azure-pipelines.yml

YAML run of pipeline

Manage Azure Pipeline runs

Once the pipeline is created, a pipeline run is triggered. You can use the az pipelines runs command group to manage pipelines runs. Use az pipelines runs list command to view all pipelines runs and az pipelines runs show command to view details pertaining to a particular run.

The az pipelines runs command group also contains the artifact and tag command sub groups which are used to manage artifacts pertaining to a run or tag a run, respectively.

Refer the az pipelines runs command documentation for details pertaining to usage and syntax.

For DevOps professionals who prefer to work from the command line, the az pipelines commands let you manage Azure Pipelines right from the terminal, without having to navigate to the portal. If you have any changes you’d like or suggestions for features then we’d love your feedback in our Azure DevOps extension GitHub Repo.