User-defined environment variables are custom variables that can be defined in the configuration
section of your pipelines YAML file.
Pipelines
In a pipeline, environment variables can be declared within the configuration
section. The environment variables declared here are available to all steps in the pipeline.
pipelines: - name: my_pipeline configuration: environmentVariables: readOnly: env1: value1 env2: value2
Steps
In a step, environment variables can be declared within the configuration
section of the step within a pipeline. The environment variables from this source are available only to the step where they are declared.
steps: - name: step_1 type: Bash configuration: environmentVariables: env1: value1 env2: value2
YAML Schema Reference
When declaring environment variables, it is important to follow YAML syntax conventions and properly quote and escape values to ensure that Pipelines can parse them correctly.
In general, YAML strings are Unicode and can be left unquoted. However, certain rules apply when using special characters. Quotes are required for strings that:
Start with a special character, such as:
:, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, @, )
Start or end with whitespace characters
Look like a number or boolean (
123
,1.23
,true
,false
,null
)
Example
Single Quotes
Example | Result | Comments |
---|---|---|
'This string 'uses single quotes'' |
|
|
|
| |
'& this string starts with a special character, needs quotes' | '& this starts with a special character, needs quotes' |
Double Quotes
Example | Result | Comments |
---|---|---|
|
| Double quotes support any character string and escape sequences. For example: |
"This string uses \ttab" |
|
Multi-line Strings
Multi-line strings can be written using:
Folded Style: Represented by a greater than symbol (>), where each line break is converted to a space.
Literal Style: Represented by a pipe (|), to preserve line breaks.
Folded Style (>)
Example | Result | Comments |
---|---|---|
|
| Folded style removes end of line characters and replaces double end of lines with single lines. This is useful for descriptions.
|
|
|
Literal Style (|)
Example | Result | Comments |
---|---|---|
|
| Literal style preserves end of line characters. This is useful when defining script actions.
|
|
|
Escape Sequences
YAML uses escape sequences as follows:
\n
is used to represent a new line\t
is used to represent a tab\\
is used to represent a slashBash style
"\ "
is used to escape additional spaces that are part of the content and should not be foldedThe trailing \ is used to represent a continuation marker. This is useful for breaking a long string into multiple lines without introducing unwanted whitespace
Example | Result | Comments |
---|---|---|
|
| Special characters must be escaped with backslash. |
|
| Backticks must be escaped as they are treated specially by the shell. |
|
| |
|
| In this example:
|