Drone provides the ability to define environment variables scoped to individual build steps. The examples in this section showcase Docker pipelines, however, the syntax is shared across all pipeline types.
Example step with custom environment variables:
|
|
Drone automatically injects environment variables containing repository and commit metadata into each pipeline step. See the environment Reference for a full list of injected variables.
Per Pipeline
Drone supports global environment variables per pipeline. Globally defined variables are automatically injected into to every pipeline step.
|
|
From Secrets
Drone provides the ability to source environment variables from secrets. In the below example we provide the username and password as environment variables to the step.
|
|
Common Problems
Parameter expansion is subject to pre-processing before the yaml is parsed. If you do not want the system to evaluate an expression it must be escaped.
|
|
Also note the environment section cannot expand environment variables or evaluate shell expressions. If you need to construct variables it should be done in the commands section.
Bad:
|
|
Good:
|
|