env

1 minute read
On this page

Use env to define variables for the workflow. Any env vars set at the workflow level are inherited by all steps in all jobs.

You cannot define variables in the env map in terms of other map variables.

env variables with the same name follow specificity precedence. In the following example, the environment variable SERVER: development defined in a step overrides SERVER: production defined in the workflow, while the step executes.

Usage example

In the following example, env that specifies SERVER: production at the workflow level is overridden by the env input in my-job, and the workflow outputs "Hello development".

apiVersion: automation.cloudbees.io/v1alpha1 kind: workflow name: My workflow on: push: branches: - '**' env: SERVER: production jobs: my-job: steps: - name: My step env: SERVER: development uses: docker://alpine:3.18 run: echo "Hello $SERVER" #prints "Hello development"