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
Community Members
Community Events
Community Groups

Is it possile to use environment variables as image name for bitbucket pipelines?


I was trying to set docker image name in `bitbucket-pipelines.yml` as a value of environment variable. Unfortunately, both ways I've tried failed:

image: $IMAGE_NAME



If I replace $IMAGE_NAME with actual value - everything works fine. 

Could you please tell me if there is a way to perform it?

Thank you,

7 answers

1 accepted

7 votes
Answer accepted

I have the same problem, seems like image name accepts only hardcoded values.

would be awesome. I just stumpled upon this issue. removed all hardcoded values from my pipeline definition and added them to team-variables so they can be changed easily without having to change bitbucket-pipeline.yml in all repositories. for everything else it works so far, just image cant be substituted.

Like Igor Bodnar likes this

I have the same issue.

It throws this error when using environment variables: There is a problem with the format of your docker image name at [image > name].

But if you goto the online validator it says it's syntactically valid with the environment variable.

My use case is that I'd like to define my AWS account id and region as environment variables so that the pipeline script is more portable between my local test BB account and the "real" repo.

The problem with the validator is that it only checks the YAML syntax. Seeing as an image name should be a string, and either `my-image:latest` or `$MY_IMAGE` is considered a string, the validator checks out. However as you already understand it doesn't interpolate variables on that specific location.

15 votes
Alex Tran Atlassian Team Jul 16, 2019

Would love to have this feature supported !

I also hope to get this one day. We regularly upgrade gradle version in and in Jenkins we have the first step extracting gradle version from this file and then uses it for the next step so we don't need to touch pipeline file every time we upgrade gradle.

How is this still not supported after almost 3 years?

So many use cases for this functionality! Please vote for this Feature Request:

Like Elgiz Abbasov likes this

Hoping to get this feature.

Been waiting for 5 years now

Vote on it please!

I have the same issue with image name, but also with max-time. For the latter, it says that value should be integer and got string. 

Where did you set the variable?

I set it in team variables also tried local project variables.

I can confirm that this isn't supported. I've tried several ways of defining the variable but all failed. Repository specific or team wide account variables aren't supported in the image name.

I'd love to see support for this!

Like # people like this

"I'd love to see support for this!" yes, please :)

Like Igor Bodnar likes this

I would also like to see this feature. How else can you use an image that has been built with a tag based on the BITBUCKET_BUILD_NUMBER?

Like # people like this

This would be a great feature. Would love to get this support.

Like Igor Bodnar likes this

That would be very handy

Like Igor Bodnar likes this

+1. Without this feature, this is not possible to declare the google container registry path dynamically for example

Like Richie likes this

it would be very useful

Like Ramila Herath likes this

would be very handy 

@David Worthington I too build an image at runtime and need to execute it. In my case a cypress test runner image. Since the step image doesnt support variables I use docker run in the script section. 

Hard to believe so basic features are not supported. I'm stating to use bb cloud for a few weeks and I'm terrrified how unmature it is comparing to GitLab.

Suggest an answer

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

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,227 views 2 9
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