Skip to content

Commit 1ce4543

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/azure-devops-docs-pr (branch live)
2 parents a603f39 + 6595f7b commit 1ce4543

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

docs/cli/azure-devops-cli-in-yaml.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.manager: mijacobs
99
ms.author: chcomley
1010
author: chcomley
1111
monikerRange: 'azure-devops'
12-
ms.date: 07/07/2025
12+
ms.date: 08/27/2025
1313
zone_pivot_groups: configure-cli
1414

1515
#customer intent: As a team member, I want to use YAML configuration files to manage my pipeline tasks by using Azure DevOps CLI.
@@ -20,9 +20,10 @@ zone_pivot_groups: configure-cli
2020

2121
[!INCLUDE [version-eq-azure-devops](../includes/version-eq-azure-devops.md)]
2222

23-
If you want to use Azure DevOps CLI with a YAML pipeline, you can use the Azure DevOps extension or use the [AzureCLI task](/azure/devops/pipelines/tasks/reference/azure-cli-v2). The Microsoft-hosted Windows and Linux agents are preconfigured with Azure CLI and the Azure DevOps CLI extension. The Azure DevOps CLI extension runs `az devops` commands.
23+
If you want to use Azure DevOps CLI with a YAML pipeline, you can use the Azure DevOps extension or use the [AzureCLI task](/azure/devops/pipelines/tasks/reference/azure-cli-v2). The Microsoft-hosted Windows and Linux agents are preconfigured with Azure CLI and the Azure DevOps CLI extension. The Azure DevOps CLI extension runs `az devops` commands.
24+
25+
You can authenticate with either a PAT or you can use the [AzureCLI@2 task](/azure/devops/pipelines/tasks/reference/azure-cli-v2) with a service connection. Using a service connection is the more secure option because you won't need to manually manage credentials.
2426

25-
You need to use a PAT with the Azure CLI extension in a pipeline. For added security, use the use the [AzureCLI task](/azure/devops/pipelines/tasks/reference/azure-cli-v2) with a service connection.
2627

2728
::: zone pivot="pat"
2829

@@ -489,7 +490,7 @@ steps:
489490
When you use a service connection, the service connection provides the necessary credentials for Azure CLI and Azure DevOps CLI commands in the AzureCLI@2 task without requiring manual credential management in the pipeline.
490491

491492
> [!NOTE]
492-
> When you use a service connection for authentication with `AzureCLI@2`, you need to [manually add the service principal to your Azure DevOps organization](../integrate/get-started/authentication/service-principal-managed-identity.md#2-add-a-service-principal-to-an-azure-devops-organization).
493+
> When you use a service connection for authentication with `AzureCLI@2`, you need to [manually add the service principal to your Azure DevOps organization](../integrate/get-started/authentication/service-principal-managed-identity.md#step-2-add-the-identity-to-azure-devops).
493494

494495
This code sample defines a new parameter, `serviceConnection`, with the name of an existing service connection. That parameter is referenced in the `AzureCLI@2` task. The task lists all projects (`az devops project list`) and pools (`az pipelines pool list`).
495496

@@ -531,13 +532,9 @@ steps:
531532
532533
## Assign the results of an Azure DevOps CLI call to a variable
533534
534-
To store the results of an Azure DevOps CLI call to a pipeline variable, use the `task.setvariable` syntax described in [Set variables in scripts](../pipelines/process/variables.md#set-variables-in-scripts). The following example gets the ID of a variable group named **Fabrikam-2023** and uses this value in a subsequent step.
535-
536-
537-
535+
To store the results of an Azure DevOps CLI call to a pipeline variable, use the `task.setvariable` syntax described in [Set variables in scripts](../pipelines/process/variables.md#set-variables-in-scripts). The following example gets the ID of a variable group named **kubernetes** and uses this value in a subsequent step.
538536

539537
```yml
540-
# Install Azure DevOps extension
541538
trigger:
542539
- main
543540
@@ -564,7 +561,8 @@ steps:
564561
az devops configure --defaults organization=$(System.CollectionUri) project=$(System.TeamProject)
565562
az devops configure -l
566563
567-
##vso[task.setvariable variable=variableGroupId]$(az pipelines variable-group list --group-name kubernetes --query [].id -o tsv)"
564+
$id = az pipelines variable-group list --group-name kubernetes --query [].id -o tsv
565+
Write-Host "##vso[task.setvariable variable=variableGroupId]$id"
568566
569567
- task: AzureCLI@2
570568
condition: succeededOrFailed()

0 commit comments

Comments
 (0)