A Variable
can be used to enable/disable elements of build/release pipelines in Azure DevOps. This GIST shows how this can be implemented within a pipeline.
Within the Variables
tab create a new variable for this toggle, and set this to a suitable default.
The following example creates a variable Deploy.Arm
that defaults to false
that can be overridden at the creation of the queue.
Note: There are some differences between Build and Release Pipelines configurations, so examples of both are shown here.
The configuration for a Build pipeline would be:
Field | Value |
---|---|
Name | Deploy.Arm |
Value | False |
Secret | False |
Settable at queue time | true |
The configuration for a Release pipeline would be:
Field | Value |
---|---|
Name | Deploy.Arm |
Value | False |
Secret | False |
Scope | Depends on usage |
Settable at release time | true |
To allow the Deploy.Arm
variable to toggle an agent phase then apply the following changes to the top level of the Agent Job
.
Expand the Additional Options
section, and update the following fields:
Field | Value |
---|---|
Run this job | Custom condition using variable expressions |
Variable expression | eq(variables['Deploy.Arm'],'true') |
To allow the Deploy.Arm
variable to toggle an Azure DevOps task then apply the following changes to the task.
Expand the Control Options
section, and update the following fields:
Field | Value |
---|---|
Run this task | Custom conditions |
Custom condition | eq(variables['Deploy.Arm'],'true') |