Skip to content

Commit 76514ac

Browse files
spasalfgheyselspim-simonsstijnmoreels
authored
docs: updated Azure DevOps feature docs for setting ARM outputs (#282)
* docs: added yaml example for Set-AzDevOpsArmOutputsToPipelineVariables * docs: added yaml example for Set-AzDevOpsArmOutputsToVariableGroup * docs: added needed variable group permissions for AzDevOpsArmOutputsToVariableGroup * docs: specified that ArmOutputs variable should only be set for Linux agents * docs: apply suggestion from code review (double space and quote syntax) * Apply suggestions from code review Added newline in between quotation block Co-authored-by: Frederik Gheysels <frederik.gheysels@telenet.be> * Apply suggestions from code review Syntax corrections and added Azure DevOps Example headers Co-authored-by: Pim Simons <32359437+pim-simons@users.noreply.github.com> * Apply suggestions from code review Added danger sign and extra info regarding Azure DevOps variable groups Co-authored-by: Stijn Moreels <9039753+stijnmoreels@users.noreply.github.com> Co-authored-by: Alex Spassov Simeonov <alex.spassov@codit.eu> Co-authored-by: Frederik Gheysels <frederik.gheysels@telenet.be> Co-authored-by: Pim Simons <32359437+pim-simons@users.noreply.github.com> Co-authored-by: Stijn Moreels <9039753+stijnmoreels@users.noreply.github.com>
1 parent f9bb8b9 commit 76514ac

1 file changed

Lines changed: 53 additions & 2 deletions

File tree

docs/preview/02-Features/powershell/azure-devops.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Stores the Azure Resource Management (ARM) outputs in a variable group on Azure
4949
| `UpdateVariablesForCurrentJob` | no | The switch to also set the variables in the ARM output as pipeline variables in the current running job |
5050

5151
**Example**
52+
5253
Without updating the variables in the current job running the pipeline:
5354

5455
```powershell
@@ -82,6 +83,34 @@ PS> Set-AzDevOpsArmOutputsToVariableGroup -VariableGroupName "my-variable-group"
8283
# The pipeline variable $variableName will be updated to value $variableValue as well, so it can be used in subsequent tasks of the current job.
8384
```
8485

86+
**Azure DevOps Example**
87+
This function is intended to be used from an Azure DevOps pipeline. Internally, it uses some predefined Azure DevOps variables.
88+
One of the environment variables that is used, is the `SYSTEM_ACCESSTOKEN` variable. However, due to safety reasons this variable is not available out-of-the box.
89+
To be able to use this variable, it must be explicitly added to the environment-variables.
90+
91+
> ⚠ When you are using a Linux agent, you need to pass other environment variables that you want to use as well, because these are not available. To be able to use the `ArmOutputs` environment variable, it must be explicitly added to the environment-variables.
92+
93+
Example of how to use this function in an Azure DevOps pipeline:
94+
95+
```yaml
96+
- task: PowerShell@2
97+
displayName: 'Promote Azure resource outputs to variable group'
98+
env:
99+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
100+
ArmOutputs: $(ArmOutputs) # only needs to be set for Linux agents
101+
inputs:
102+
targetType: 'inline'
103+
script: |
104+
Install-Module -Name Arcus.Scripting.DevOps -Force
105+
106+
Set-AzDevOpsArmOutputsToVariableGroup -VariableGroupName "my-variable-group"
107+
```
108+
109+
In Azure DevOps, below permissions need to be set on your variable group in order to make the 'Promote Azure resource outputs to variable group' task succeed. For more information on service accounts, see [the official Azure DevOps documentation](https://docs.microsoft.com/en-us/azure/devops/organizations/security/permissions?view=azure-devops&tabs=preview-page#service-accounts).
110+
111+
- Project Collection Build Service (`<your devops org name>`) - Administrator
112+
- `<your devops project name>` Build Service (`<your devops org name>`) - Administrator
113+
85114
## Setting ARM outputs to Azure DevOps pipeline variables
86115

87116
Sets the ARM outputs as variables to an Azure DevOps pipeline during the execution of the pipeline.
@@ -91,6 +120,7 @@ Sets the ARM outputs as variables to an Azure DevOps pipeline during the executi
91120
| `ArmOutputsEnvironmentVariableName` | no | The name of the environment variable where the ARM outputs are located (default: `ArmOutputs`) |
92121

93122
**Example**
123+
94124
With default `ArmOutputs` environment variable containing: `"my-variable": "my-value"`:
95125

96126
```powershell
@@ -109,6 +139,26 @@ PS> Set-AzDevOpsArmOutputsToPipelineVariables -ArmOutputsEnvironmentVariableName
109139
# ##vso[task.setvariable variable=my-variable]my-value
110140
```
111141

142+
**Azure DevOps Example**
143+
This function is intended to be used from an Azure DevOps pipeline.
144+
145+
> ⚠ When you are using a Linux agent, you need to pass other environment variables that you want to use as well, because these are not available. To be able to use the `ArmOutputs` environment variable, it must be explicitly added to the environment-variables.
146+
147+
Example of how to use this function in an Azure DevOps pipeline:
148+
149+
```yaml
150+
- task: PowerShell@2
151+
displayName: 'Promote Azure resource outputs to pipeline variables'
152+
env:
153+
ArmOutputs: $(ArmOutputs) # only needs to be set for Linux agents
154+
inputs:
155+
targetType: 'inline'
156+
script: |
157+
Install-Module -Name Arcus.Scripting.DevOps -Force
158+
159+
Set-AzDevOpsArmOutputsToPipelineVariables
160+
```
161+
112162
## Save Azure DevOps build
113163

114164
Saves/retains a specific Azure DevOps pipeline run.
@@ -126,8 +176,9 @@ PS> Save-AzDevOpsBuild -ProjectId $(System.TeamProjectId) -BuildId $(Build.Build
126176
# Information on them can be found here: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
127177
```
128178

129-
This function is intended to be used from an Azure DevOps pipeline. Internally, it uses some predefined Azure DevOps variables.
130-
One of the environment variables that is used, is the the `SYSTEM_ACCESSTOKEN` variable. However, due to safety reasons this variable is not available out-of-the box.
179+
**Azure DevOps Example**
180+
This function is intended to be used from an Azure DevOps pipeline. Internally, it uses some predefined Azure DevOps variables.
181+
One of the environment variables that is used, is the `SYSTEM_ACCESSTOKEN` variable. However, due to safety reasons this variable is not available out-of-the box.
131182
To be able to use this variable, it must be explicitly added to the environment-variables.
132183

133184
Example of how to use this function in an Azure DevOps pipeline:

0 commit comments

Comments
 (0)