We have a number of keys that are used by all of our builds (but are different for each of our environments) and we would like to store these as workspace variables - but expose these in each of our deployments by referencing the workspace variables.e.g.Workspace Variables PROD_KEY STAGING_KEY DEV_KEYDeployments Dev: KEY=$DEV_KEY Staging: KEY=$STAGING_KEY Production: KEY=$PROD_KEY script: - echo $KEYIs there any way of having a deployment variable reference a workspace variable?
Hey Alan!
I have just tested on my end and can confirm the exact configuration you have defined will work to reference workspace-level variables IF those workspace-level variables are unsecured, as you are able to reference both deployment/workspace variables when running a pipelines build.
For more information please refer to the following link:https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
Cheers!
- Ben (Bitbucket Cloud Support)
The variables the user asked about were "KEYS" so they probably need to be secured.
Your saying this won't work for secured workspace variables?
Is there just a way to define environments at the workspace level?
Hey Ben,
Yes, the idea behind "secured" variables is that they are secure and therefore echoing them will not reveal the values inside these.
There is some text when configuring workspace variables from within Workspace Settings > Pipelines > Workspace Variables that defines the above:
Environment variables added at the workspace level can be accessed from all repositories that are within that workspace. To access a variable, put the $ symbol in front of its name. For example, access AWS_SECRET by using $AWS_SECRET. Workspace variables can be overridden by variables added on the repository level. If you want the variable to be stored unencrypted and shown in plain text in the logs, unsecure it by unchecking the checkbox.
Environment variables added at the workspace level can be accessed from all repositories that are within that workspace. To access a variable, put the $ symbol in front of its name. For example, access AWS_SECRET by using $AWS_SECRET. Workspace variables can be overridden by variables added on the repository level.
If you want the variable to be stored unencrypted and shown in plain text in the logs, unsecure it by unchecking the checkbox.
Environments can only be defined at the repository level from within Repository Settings > Pipelines > Deployments.
It looks like you're new here. Sign in or register to get started.