Set environment variables for each workflow in a stage

Is it possible to set environment variables for a workflow within a stage? e.g.

stages:
  test:
    workflows:
    - all_tests: {}
  build:
    workflows:
    - single_scheme: {
      flavour: production
    }
    - single_scheme: {
      flavour: staging
    }

Hey @lukewakefordpassenge

Thanks for posting your question!

Yes, it is possible to set environment variables for a workflow within a stage.
Add the following code to the bitrise.yml file:

format_version: 1.3.1
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

stages:
  test:
    workflows:
      - all_tests: {}
  build:
    workflows:
      - single_scheme:
          flavour: production
      - single_scheme:
          flavour: staging

Next, add the environment variables to the workflows. For example:

format_version: 1.3.1
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

stages:
  test:
    workflows:
      - all_tests:
          envs:
            - ENV_VAR_ONE: first value
            - ENV_VAR_TWO: second value
  build:
    workflows:
      - single_scheme:
          flavour: production
          envs:
            - ENV_VAR_ONE: first value
            - ENV_VAR_TWO: second value
      - single_scheme:
          flavour: staging
          envs:
            - ENV_VAR_ONE: first value
            - ENV_VAR_TWO: second value

Save the bitrise.yml file.

Run the bitrise command to execute the workflows:

bitrise run all_tests 
bitrise run single_scheme:production 
bitrise run single_scheme:staging

Please let us know if this helped or if you need further assistance.

Thanks again,
Leilah

Hey thanks for the pointers.

Is it possible to run the whole pipeline or an individual stage from the cli? e.g.

bitrise run test or bitrise run build ?

Right now these commands error with:

specified Workflow (test) does not exist

Yes, it is possible to run the whole pipeline or an individual stage from the Bitrise CLI.

Typically to run an individual stage, you need to specify the Workflow ID in the bitrise run command: bitrise run <WORKFLOWID>

Before doing that though, can you make sure that the Workflow ID is correctly specified in the bitrise.yml file. The Workflow ID should match the ID of the Workflow you are trying to run.

Now to further troubleshoot the error:

  1. Check the bitrise.yml file to make sure the Workflow with the name โ€˜testโ€™ exists.

  2. If the Workflow exists, check the configuration of the Workflow to make sure it is set up correctly. This includes checking the Step names, Step inputs, Step outputs, Environment Variables, and other configurations are correctly specified.

Please let me know if this was helpful or if you need additional assistance.

Thanks again,
Leilah