How to schedule builds in web panel with overriding BITRISE_SCHEME

Hello!

Before posting this question I did try to setup this myself, I read How to override environment variables through the Build Trigger API & Build Trigger API - Bitrise DevCenter. I don’t think that Build Trigger API will solve my case or…I didn’t understand build trigger API and I’m missing something.

Setup
I use a combination of bitrise.yml & Fastfile to run my builds. In terms of Bitrise setup, almost everything is configured via bitrise.yml. So, at the beginning of a file I have

app:
  envs:
    - BITRISE_SCHEME: iOS_target_1

Before I continue it’s worth mentioning that in project I have four different targets configured (iOS_target_1, iOS_target_2, etc…). Until now I released one target at once but now I would like to setup nightly builds. So that during day current target is building (iOS_target_1) but at the end of a day, all other apps are build by Bitrise (iOS_target_2, iOS_target_3, etc).
I tried with removing BITRISE_SCHEME from bitrise.yml and adding it to $Env Vars tab in Workflow settings. I thought that by adding BITRISE_SCHEME: iOS_target_2 in Custom Environment Variables(optional) when starting/scheduling a build, iOS_target_2 will be executed but no luck. Still, target provided in $Env Vars is executed.
I would like to avoid invoking curls on my side, I would like to use Bitrise’s scheduling system for that. However, I have no idea how to configure it to override env var specified in web panel.

Best,
Pikor

Hi @pikor,

Great question!

My suggestion would be to specify a workflow for these Schemes, and simply overwrite that Env Var (BITRISE_SCHEME). On the Env Var tab you can configure per workflow env vars, not just global / “app” level ones. Workflow level ones can overwrite app level ones (related docs: https://devcenter.bitrise.io/bitrise-cli/most-important-concepts/#availability-order-of-environment-variables )

Note: if all you want to change is env vars, then you can use Workflow Chaining (https://devcenter.bitrise.io/bitrise-cli/workflows/#chaining-workflows-and-reusing-workflows). In the https://devcenter.bitrise.io/bitrise-cli/workflows/#note-about-workflow-environment-variables section you can see an example where e.g. the build-alpha workflow does nothing else just sets an env var then runs the generic-build workflow. Similarly build-beta sets that env var to a different value, then runs generic-build.

If you’d have any questions just let us know! :slight_smile:

Thank you @viktorbenei! Using informations from https://devcenter.bitrise.io/bitrise-cli/workflows/#note-about-workflow-environment-variables I was able to set it up! :slight_smile:

Just in case someone else will be looking for a solution in the future.
In bitrise.yml I created new workflow

  build-fabric-nightly-iOS_target_2:
    envs:
      - BITRISE_SCHEME: iOS_target_2
    after_run:
      - staging 

and because of that, global BITRISE_SCHEME is overridden. Then you need to set up workflow in Bitrise web panel to run bitrise run build-fabric-nightly-iOS_target_2 and everything works great!

2 Likes

Exactly - thanks for sharing the yml snippet @pikor! :wink: