Create and manage Azure Pipelines from the command line

George

July 11th, 2019

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

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.