Setting Environment Variables#
Semaphore supports setting environment variables for an individual job, for all jobs in a block, and for all jobs in a pipeline.
If you're looking for a list of environment variables which Semaphore sets in every job, refer to the CI/CD Environment guide.
Using Workflow Builder#
To set a new environment variable:
- Open Workflow Builder.
- Select a block or job to which you would like to export environment variables.
- Click Environment variables.
- Click Add env vars.
- Fill in the variable's key and value.
- Optionally, add more variables.
- Click Run the workflow to save your configuration and run a new workflow.
YAML example#
Here's an example which applies an environment variable to all jobs in the block:
# .semaphore/semaphore.yml
blocks:
- name: "Test"
task:
env_vars:
- name: GUIDED_TOUR
value: "TRUE"
jobs:
- name: Lint
commands:
- echo "${GUIDED_TOUR}"
- echo 'Linting code'
- name: Unit
commands:
- echo "${GUIDED_TOUR}"
- echo 'Unit tests'
Note: Numeric values need to be included in quotes.