View on GitHub

Arcus Scripting

Scripting with Microsoft Azure in a breeze.

Azure DevOps

This module provides the following capabilities:

Installation

To have access to the following features, you have to import the module:

PS> Install-Module -Name Arcus.Scripting.DevOps

Setting a variable in an Azure DevOps pipeline

Assign a value to a DevOps pipeline variable during the execution of this pipeline.

Parameter Mandatory Description
Name yes The name of the variable to set in the pipeline
Value yes The value of the variable to set in the pipeline

Example

PS> Set-AzDevOpsVariable "my-variable" "my-variable-value"
# #vso[task.setvariable variable=my-variable] my-variable-value

Setting ARM outputs to Azure DevOps variable group

Stores the Azure Resource Management (ARM) outputs in a variable group on Azure DevOps.

Parameter Mandatory Description
VariableGroupName yes The name of the variable group on Azure DevOps where the ARM outputs should be stored
ArmOutputsEnvironmentVariableName | no | The name of the environment variable where the ARM outputs are located (default: ArmOutputs`)    
UpdateVariablesForCurrentJob no The switch to also set the variables in the ARM output as pipeline variables in the current running job

Example Without updating the variables in the current job running the pipeline:

PS> Set-AzDevOpsArmOutputsToVariableGroup -VariableGroupName "my-variable-group"
# Get ARM outputs from 'ArmOutputs' environment variable
# Adding variable $output.Name with value $variableValue to variable group my-variable-group
# Retrieving project details
# Set properties for update of existing variable group

Include updating the variables in the current job running the pipeline, to immediately make them available to the next pipeline tasks:

PS> Set-AzDevOpsArmOutputsToVariableGroup -VariableGroupName "my-variable-group" -UpdateVariablesForCurrentJob
# Get ARM outputs from 'ArmOutputs' environment variable
# Adding variable $output.Name with value $variableValue to variable group my-variable-group
# Retrieving project details
# Set properties for update of existing variable group
# The pipeline variable $variableName will be updated to value $variableValue as well, so it can be used in subsequent tasks of the current job. 
# ##vso[task.setvariable variable=$variableName]$variableValue

Include user-defined environment variable for the ARM outputs:

PS> Set-AzDevOpsArmOutputsToVariableGroup -VariableGroupName "my-variable-group" -ArmOutputsEnvironmentVariableName "MyArmOutputs"
# Get ARM outputs from 'MyArmOutputs' environment variable
# Adding variable $output.Name with value $variableValue to variable group my-variable-group
# Retrieving project details
# Set properties for update of existing variable group
# The pipeline variable $variableName will be updated to value $variableValue as well, so it can be used in subsequent tasks of the current job.