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:

  1. Open Workflow Builder.
  2. Select a block or job to which you would like to export environment variables.
  3. Click Environment variables.
  4. Click Add env vars.
  5. Fill in the variable's key and value.
  6. Optionally, add more variables.
  7. 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
  - name: "Test"
        - name: GUIDED_TOUR
          value: "TRUE"
        - name: Lint
            - echo "${GUIDED_TOUR}"
            - echo 'Linting code'
        - name: Unit
            - echo "${GUIDED_TOUR}"
            - echo 'Unit tests'

Note: Numeric values need to be included in quotes.