Is it possible to reference account variables from deployment variables?
The use case is the following:
- I have multiple repositories which uses the same set of secrets for each Dev, Staging and Production environments. (so 1 set per env)
- Instead of specifieng these in each repository again (duplication), I add the generic Dev, Staging and Prod keys to Account Variables.
- I would like to do the following in 'Deploymenent Variables': GOOGLE_SECRET = $GOOGLE_SECRET_DEV (if deployment stage is 'DEV') or GOOGLE_SECRET = $GOOGLE_SECRET_STG (if deployment stage is 'Staging'). - Where GOOGLE_SECRET_DEV is specified as Account variable.
This way I, able to reuse 'steps' more easyly because I can now use the generic GOOGLE_SECRET, instead of defining different steps for each env.
I'm not aware about a generic variable reference feature inside Atlassian Bitbucket Cloud Pipelines plugin specifically.
However as far as a POSIX compatible shell is at your option (e.g. a pipeline step script), the shell has it covered:
- eval "GOOGLE_SECRET=\${$GOOGLE_SECRET_ENV}"; export GOOGLE_SECRET
Where GOOGLE_SECRET_ENV is "GOOGLE_SECRET_DEV" or "GOOGLE_SECRET_STG" respectively.
If you follow a specific naming convention, the BITBUCKET_DEPLOYMENT_ENVIRONMENT variable might be of use to make this kind of mapping even more implicit. It has the name of the deployment environment as configured. So you can have "preconfigured" environments from the account variables.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.