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

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 access deployment environment variables in more than one step?

Is possible?

2 answers

it seems odd that his limitation exists.

could this be added as a feature?

our use case is to write client secrets from Deployment Variables into a file, and in the next step run a pipe which requires those variables.

otherwise I need to quit using the pipe, and script this all out.

0 votes

Hi @Danilo Gentil Setúbal 

An environment can only be deployed to from one step in the pipeline.

You can define the same variable on different environments however and each step will get the value associated with the environment it deploys to.

You can also define account and repository level variables that are available to every step in the pipeline.

For example if you define:

  • A repository level variable: MY_VAR with value my_repo_var
  • A deployment variable on the Test environment: MY_VAR with value my_test_var
  • A deployment variable on the Production environment: MY_VAR with value my_prod_var

Then this pipeline:

pipelines:
default:
- step:
script:
- echo $MY_VAR
- step:
deployment: test
script:
- echo $MY_VAR
- step:
deployment: production
script:
- echo $MY_VAR
- step:
script:
- echo $MY_VAR

will produce the following output:

my_repo_var

my_test_var

my_prod_var

my_repo_var

Please see the following page in our documentation for more information on variables: https://confluence.atlassian.com/bitbucket/variables-in-pipelines-794502608.html

Suggest an answer

Log in or Sign up to
This widget could not be displayed.
TAGS
Community showcase
Posted in Bitbucket

How do you use the Bitbucket-Jira integration? How does it help your team?

Hey everyone, over the past year, we've added several new features on how you can use Bitbucket and Jira together. We'd love to know how you are using the integration and how it's helping your team...

894 views 5 3
Join discussion

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