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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to reference account variables from deployment variables?

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.

1 answer

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,227 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you