Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Define variables using name/value pairs.
Definitions that reference this definition: pipeline, stages.stage, jobs.job, jobs.deployment
Implementation | Description |
---|---|
variables: string dictionary | Define variables using name/value pairs. |
variables: variable list | Define variables by name, variable group, or in a template. |
The variables
keyword uses two syntax forms: variable list and mapping (string dictionary).
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.
Define variables using name/value pairs.
variables:
string: string # Name/value pairs
None.
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)
Define variables by name, variable group, or in a template.
variables: [ name | group | template ] # Define variables by name, variable group, or in a template.
Type | Description |
---|---|
variables.name | Define variables using name and full syntax. |
variables.group | Reference variables from a variable group. |
variables.template | Define variables in a template. |
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
Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now