Setting Environment Variables#

Semaphore supports setting environment variables on a per-block and per-job level.

If you're looking for a list of environment variables which Semaphore sets in every job, refer to CI/CD Environment guide.

Using Workflow Builder#

To set a new environment variable:

  1. Open Workflow Builder.
  2. Select a block or job where 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 one 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'