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

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,

6 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.

14 votes
Alex Tran Atlassian Team Jul 16, 2019

Would love to have this feature supported !

1 vote

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.

Hoping to get this feature.

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. 

0 votes
Danyal Iqbal Community Leader Jun 01, 2018

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

Suggest an answer

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

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,741 views 10 16
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