When trying to use the Build Trigger API to overwrite an Env Var which is defined in the build configuration, simply specifying that variable in the API will not work.
Environment Variables are processed in a specific order, which means that an Environment Variable processed before another one can’t override the second one, only the other way around.
If you use the Build Trigger API and you specify one-off Environment Variables as parameters of the build, those will be processed AFTER the Secret Env Vars, but BEFORE App Env Vars.
This means that the value of the App Env Var will be used as it will override the value you specify through the API.
How can you override a variable which is defined in the build configuration? We recommend you override it at a later stage: You can do this with a build Step, for example, with a Script Step. Steps and Step outputs are processed after App Env Vars and Workflow Env Vars, so with this solution you can reliably override any other Environment Variable.
The key is to specify an Environment Variable through the API which is NOT defined in your build configuration, and then copy the value of this Env Var to the main one, overriding it.
For example, if you want to override the Environment Variable
BITRISE_SCHEME, you should specify, for example, an
API_BITRISE_SCHEME Env Var, and then copy the value of