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

Repo env var in image line

Hi,

I am using a custom docker image in my deployment pipeline. Works great.

However, it seems very sensible to me to maintain the docker version in an environment variable in the repository, so I can change it via the repo, and not with a code release.

This is because many projects use this single image to deploy, and changes to the image need to be handled correctly.

I don't want to have to do a code release for each project to simply change the version number of the deployment image. And I also need to know that they are going to work even if I do a new version of the image.

I'd want to move them over to the one by one, ensuring that they are still working as before, adding new env vars to the repo if need be or what ever is required.

Step code in pipelines :

- step:
name: DEVELOP - Deploy Complete
deployment: test
trigger: manual
image:
name: my-dockerhub-repo/my-docker-image:$DOCKER_VERSION
username: $DOCKER_HUB_USERNAME
password: $DOCKER_HUB_PASSWORD
email: $DOCKER_HUB_EMAIL

I think line :

name: my-dockerhub-repo/my-docker:$DOCKER_HUB_VERSION

Should be acceptable. However, I get an error :

There is a problem with the format of your docker image name at [pipelines > branches > develop > 1 > step > image > name].

Presumably this is from a syntax check as it doesn't even run.

Any ideas how I can achieve this please ?

Thanks

 

2 answers

1 accepted

2 votes
Answer accepted

Hello Jowan,

Currently only the username, password, and email support environment variable values. The image name does not support having environment variables.

If you'd like, you can open a feature request to support this here: https://bitbucket.org/site/master/issues/new

Depending on what you're doing, you could alternatively pull this image inside of your build script instead using Docker and run the relevant tests inside of the running container.

Thanks,

Phil

Hi Phil,

Thanks for the response.

Yes I see the (nested) docker solution and may use that, a mini docker just to spin up another docker with version number passed is a bit overkill though.

Definitely going to feature request it.

Thanks

We had this error message:

There is a problem with the format of your docker image name at [image > name].

We tried to have image set like this:

   name: $DOCKER_REGISTRY/bitbucket-pipeline-image-ubuntu18:latest

 You should at least update the documentation here:
https://confluence.atlassian.com/bitbucket/use-docker-images-as-build-environments-792298897.html
image.pngWith this information:

The image name does not support having environment variables.

Like Sean Reifschneider likes this

Suggest an answer

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

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,053 views 0 3
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