Edit

Share via


Azure DevOps CLI in a release pipeline

Azure DevOps Services

To use the Azure DevOps CLI in a hosted agent using a Release Pipeline, do the following steps:

  1. Create a release pipeline.

    Screenshot shows the Pipeline page with the option to create a new release pipeline.

  2. Select Empty job.

    Screenshot shows the Select a template page with the Empty job link highlighted.

  3. Select Stage 1 to configure the stage.

    Screenshot shows the New release pipeline page with Stage 1 highlighted.

  4. Select the Tasks page, and configure the job to use Hosted macOS in Agent Pools.

    Screenshot shows the Tasks tab for Stage 1, which displays Agent job configuration.

  5. Select the plus icon to add another task and configure it as a PowerShell task. To filter the list, enter Power into the search box.

    Screenshot shows the Tasks tab for Agent job with the Add tasks option.

  6. Add the script, either by using file or inline. For this example, the script is included inline.

    Screenshot shows an Azure PowerShell script included for the task.

  7. There might be more configuration steps for your pipeline. When you finish all steps, select Save.

Here's the inline script for this example:

$extensions = az extension list -o json | ConvertFrom-Json

$devopsFound = $False
foreach($extension in $extensions)
{
    if($extension.name -eq 'azure-devops'){
        $devopsFound = $True
    }
}

if ($devopsFound -eq $False){
    az extension add -n azure-devops
}