Skip to content

Commit 5f4104d

Browse files
committed
Fix YAML error in AzureCLI@2 example
1 parent 8abd308 commit 5f4104d

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

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

Lines changed: 7 additions & 9 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

@@ -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)