Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,459,211
Community Members
 
Community Events
176
Community Groups

Using Workspace variables in deployment variables

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_KEY

Deployments
   Dev:
      KEY=$DEV_KEY
   Staging:
      KEY=$STAGING_KEY
   Production:
      KEY=$PROD_KEY 

script:
   - echo $KEY


Is there any way of having a deployment variable reference a workspace variable?

1 answer

0 votes
Ben Atlassian Team Mar 13, 2022

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?

Like Drew Heasman likes this
Ben Atlassian Team Jul 12, 2022

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.

Environments can only be defined at the repository level from within Repository Settings > Pipelines > Deployments.

Cheers!

- Ben (Bitbucket Cloud Support)

Like Douglas Carmo likes this

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events