Missed Team ’24? Catch up on announcements here.

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

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

Aleksei Terentev June 1, 2018

Hello,

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:

step:
image: $IMAGE_NAME

 and 

step:
image:
name: $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
Deleted user June 19, 2018

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

Marco Röhrs
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!
August 20, 2019

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
nickjj
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!
September 15, 2019

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.

Erik van der Valk
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!
September 16, 2019

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.

Like Antonius Golly likes this
16 votes
Alex Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 16, 2019

Would love to have this feature supported !

2 votes
Denis Kalgushkin
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!
August 2, 2021

I also hope to get this one day. We regularly upgrade gradle version in gradle.properties 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.

1 vote
Elgiz Abbasov November 9, 2021

How is this still not supported after almost 3 years?

Pavel Shurikov November 29, 2021

So many use cases for this functionality! Please vote for this Feature Request: https://jira.atlassian.com/browse/BCLOUD-13014

Like Elgiz Abbasov likes this
1 vote
Rajan Paneru
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!
February 5, 2021

Hoping to get this feature.

Pavel Shurikov November 29, 2021

Been waiting for 5 years now https://jira.atlassian.com/browse/BCLOUD-13014

Vote on it please!

0 votes
golaod
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!
September 21, 2020

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 1, 2018

Where did you set the variable?

Aleksei Terentev June 1, 2018

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

Erik van der Valk
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!
October 11, 2018

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
Marco Röhrs
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!
September 16, 2019

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

Like Igor Bodnar likes this
David Worthington
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!
October 10, 2019

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
praveenselvam
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!
November 5, 2019

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

Like Igor Bodnar likes this
Luiz Oliveira
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 20, 2020

That would be very handy

Like Igor Bodnar likes this
Arnaud Busson
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!
May 7, 2020

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

Like Richie likes this
Simone De Cristofaro
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 1, 2021

it would be very useful

Like Ramila Herath likes this
Ramila Herath
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!
November 23, 2021

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. 

Marcin Jarzembowski
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!
June 29, 2022

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.

Chandrahasa Kotyan November 29, 2022

It will reduce the need to commit pipeline files when we need the pipeline to use  a different image (say node or Python upgrade cases)

Rutger Deterd Oude Weme June 7, 2023

I've also voted. Would be great feature to have

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events