This question relates to the secrets and env vars tabs. I am trying to avoid using scripts with envman.
First off, why can’t you set secrets for different workflows like you can environment vars? What if I have a different secret key for each environment I need to build for?
Second, starting to play with Secrets and Env Vars and I have a few usage questions which I could not find documented.
Can Secrets reference Env Vars such as:
AUTH_ISSUER=$SSO_URL
Can Env Vars reference other Env Vars such as:
MY_BUILD_NUM=$BITRISE_BUILD_NUM
ENVIRONMENT_NAME=nightly
BASE_URL=${ENVIRONMENT_NAME}.company.com
API_URL=https://api-${BASE_URL}
Can Env Vars reference Secrets such as:
(This seems necessary because secrets can’t be split up based on workflow)
In the value of a Secret Environment Variable, you can use Environment Variables exposed by Bitrise CLI, but you can’t use any other Environment Variable (App Env Vars, Workflow Env Vars, and so on), as those are not processed when Secrets are processed.
Can Env Vars reference other Env Vars:
In the value of an App Env Var , you can use environment variables from Secrets as well as the Bitrise CLI exposed ones, but you can’t use Workflow Env Vars or Step inputs
Can Env Vars reference Secrets:
In a Workflow environment variable you can use all the above ( Secrets , App Env Vars , Bitrise CLI exposed env vars).
These seem to answer my questions, although now new questions arise:
How do you “use” other variables? I didn’t see any syntax examples. Are the following acceptable?
MY_BUILD_NUM=$BITRISE_BUILD_NUM
API_URL=“https://api-${BASE_URL}”
I read this:
If the workflow has workflows chained before or after it, the environment variables of the chained workflows are processed and made available right before the first step of the workflow would run.
If I have a generic setup workflow, and then I have environment specific build workflows. Can the setup workflow depend on workflow specific environment variables being set before the setup workflow is ran. This wasn’t entirely clear to me based on the above statement.
Regarding the chained workflows, the setup workflow is using workflow environment variables that are set on the build- workflow it is chained to which is good news.
As far as is_expand, “Replace variables in Inputs”, and “Expose for pull requests”, I guess I don’t really understand those concepts yet.
If flag is true then variables in inputs are evaluated by CLI before executing the step eg. $CI will be evaluated to either "true" or "false". OTOH if flag is false then nothing is evaluated and $CI stays "$CI".
If it is disabled then variable won’t exist in PR builds.
The Expose for Pull Request toggle can be enabled if you want your secrets to be exposed in your build logs in pull requests.
Does this mean they won’t show up in the build logs or they just aren’t available at all?
I’ve been having builds start to fail that are triggered by PRs, and the logs don’t seem to indicate why. I recently started storing auth related values in the secrets.