Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Use an environment variable to set the deployment environment

Matthew Elwell
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 30, 2019

We have our environments named using the same terms as our branches so our bitbucket-pipelines.yml should be as simple as: 

 

image: python:3.7

pipelines:
default:
- step:
name: deploy to $BITBUCKET_BRANCH
deployment: $BITBUCKET_BRANCH
script:
- deploy.py $BITBUCKET_BRANCH

 

When validating this yml, however, it appears that it's not possible to use a variable to define the 'deployment' environment as 'Environment names can use letters, spaces, numbers, underscores or hyphens'. 

 

Is there a way to use an environment variable to define the deployment environment as per the example above? 

1 answer

1 accepted

0 votes
Answer accepted
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 9, 2019

Hi @Matthew Elwell

I see you are new here, welcome!

Answering your question:

Is there a way to use an environment variable to define the deployment environment as per the example above? 

No, you cannot use variables for that field as you already discovered. There is a check to cover only the three valid values which are: teststaging, and production. The parser does not allow variables there. You will need to declare each of the values separately.

For more details on our deployment feature, please visit Bitbucket Deployments.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events