variables definition
Define variables to use in your pipeline.
Properties that use this definition: pipeline.variables, jobs.job.variables
Properties that use this definition: pipeline.variables, jobs.job.variables
Properties that use this definition: pipeline.variables, stages.stage.variables, jobs.job.variables, jobs.deployment.variables
Properties that use this definition: pipeline.variables, stages.stage.variables, jobs.job.variables, jobs.deployment.variables
Properties that use this definition: pipeline.variables, stages.stage.variables, jobs.job.variables, jobs.deployment.variables
Properties that use this definition: pipeline.variables, stages.stage.variables, jobs.job.variables, jobs.deployment.variables
Overloads
| Overload | Description |
|---|---|
| variables: string pairs | Define variables using name/value pairs. |
| variables: variable list | Define variables by name, variable group, or in a template. |
| Overload | Description |
|---|---|
| variables: string pairs | Define variables using name/value pairs. |
| variables: variable list | Define variables by name, variable group, or in a template. |
| Overload | Description |
|---|---|
| variables: string pairs | Define variables using name/value pairs. |
| variables: variable list | Define variables by name, variable group, or in a template. |
| Overload | Description |
|---|---|
| variables: string pairs | Define variables using name/value pairs. |
| variables: variable list | Define variables by name, variable group, or in a template. |
| Overload | Description |
|---|---|
| variables: string pairs | Define variables using name/value pairs. |
| variables: variable list | Define variables by name, variable group, or in a template. |
| Overload | Description |
|---|---|
| variables: string pairs | Define variables using name/value pairs. |
| variables: variable list | Define variables by name, variable group, or in a template. |
Remarks
The variables keyword uses two syntax forms: list and mapping.
In mapping syntax, all keys are variable names and their values are variable values. To use variable templates, you must use list syntax. List syntax requires you to specify whether you're mentioning a variable (name), a variable group (group), or a template (template).
You can't use list and mapping variables in the same variables section, but you can combine name, group, and template when using list syntax.
You can specify variables at the pipeline, stage, or job level.
variables: string pairs
You can specify variables as string/value pairs.
variables:
string: string # Name/value pairs.
Properties
mapping
string name/value pairs
variables:
string: string # Name/value pairs.
Properties
mapping
string name/value pairs
variables:
string: string # Name/value pairs.
Properties
mapping
string name/value pairs
variables:
string: string # Name/value pairs.
Properties
mapping
string name/value pairs
variables:
string: string # Name/value pairs.
Properties
mapping
string name/value pairs
variables:
string: string # Name/value pairs.
Properties
mapping
string name/value pairs
Examples
For a simple set of hard-coded variables, use this mapping syntax:
variables: { string: string }
Variables defined at different scopes:
variables: # pipeline-level
MY_VAR: 'my value'
ANOTHER_VAR: 'another value'
stages:
- stage: Build
variables: # stage-level
STAGE_VAR: 'that happened'
jobs:
- job: FirstJob
variables: # job-level
JOB_VAR: 'a job var'
steps:
- script: echo $(MY_VAR) $(STAGE_VAR) $(JOB_VAR)
variables: # pipeline-level
MY_VAR: 'my value'
ANOTHER_VAR: 'another value'
jobs:
- job: FirstJob
variables: # job-level
JOB_VAR: 'a job var'
steps:
- script: echo $(MY_VAR) $(STAGE_VAR) $(JOB_VAR)
variables: variable list
Specify variables using the full syntax.
variables: [ name | group | template ] # Define variables by name, variable group, or in a template.
Properties
variables
variables: [ name | group | template ] # Define variables by name, variable group, or in a template.
Properties
variables
variables: [ name | group | template ] # Define variables by name, variable group, or in a template.
Properties
variables
variables: [ name | group | template ] # Define variables by name, variable group, or in a template.
Properties
variables
variables: [ name | group | template ] # Define variables by name, variable group, or in a template.
Properties
variables
variables: [ name | group | template ] # Define variables by name, variable group, or in a template.
Properties
variables
Examples
To include variable groups, switch to this sequence syntax:
variables:
- name: string # name of a variable
value: string # value of the variable
- group: string # name of a variable group
You can repeat name/value pairs and group.
Variables can also be set as read only to enhance security.
variables:
- name: myReadOnlyVar
value: myValue
readonly: true
You can also include variables from templates.
Sequence syntax:
variables:
- name: MY_VARIABLE # hard-coded value
value: some value
- group: my-variable-group-1 # variable group
- group: my-variable-group-2 # another variable group
See also
Feedback
Submit and view feedback for