Create
cancel
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

How to push multiple tags with ECR push pipelines Edited

I am trying to push multiple Tags with

pipe: atlassian/aws-ecr-push-image:0.1.2

 

i need something like 

TAG: '${BITBUCKET_BUILD_NUMBER}:latest'

 

2 answers

Update: This solution doesn't work, please use @james_twigg's solution instead.

You can apply multiple tags to your image before using the pipe. All tags will be pushed by the pipes at once

script:
  - docker build -t <image-name> -t <docker-repository>/<image-name>:${BITBUCKET_BUILD_NUMBER} .
- docker tag <docker-repository>/<image-name>:${BITBUCKET_BUILD_NUMBER} <docker-repository>/<image-name>:latest
- pipe: atlassian/aws-ecr-push-image:0.1.2 variables: AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION IMAGE_NAME: <image-name>

You can also have a look at the similar question in StackOverflow: https://stackoverflow.com/a/31963727/2183102

Thanks Alexander

I tried this

- docker build -t <IMAGE_NAME> -t ${AWS_REGISTRY_URL}:${BITBUCKET_BUILD_NUMBER} .
- docker tag ${AWS_REGISTRY_URL}:${BITBUCKET_BUILD_NUMBER} ${AWS_REGISTRY_URL}:latest
- pipe: atlassian/aws-ecr-push-image:0.1.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: <IMAGE_NAME>

 

AWS_REGISTRY_URL is like <AWS_ACCOUNT_NUMBER>.dkr.ecr.eu-west-1.amazonaws.com/<IMAGE_NAME>

 

still getting only default TAG 'latest'

Like james_twigg likes this

Hi Yadvendra,

I encountered the same problem with `aws-ecr-push-image:0.1.3`, only the 'latest' tag would be set.

As a workaround I included two instances of the pipe in the step:

- docker build -t <IMAGE_NAME>:latest -t <IMAGE_NAME>:${BITBUCKET_BUILD_NUMBER} .
- pipe: atlassian/aws-ecr-push-image:0.1.3
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: <IMAGE_NAME>
TAG: latest
- pipe: atlassian/aws-ecr-push-image:0.1.3
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: <IMAGE_NAME>
TAG: ${BITBUCKET_BUILD_NUMBER}

The image was not actually uploaded again but the extra tag was added to the image uploaded as 'latest'.

Like # people like this

Thanks James,

I tried your solution but got the error

--env=TAG="${BITBUCKET_BUILD_NUMBER}" \ --add-host="host.docker.internal:$BITBUCKET_DOCKER_HOST_INTERNAL" \ bitbucketpipelines/aws-ecr-push-image:0.1.3✖ Validation errors: TAG:- must be of string type

 

my pipeline is like this

- docker build -t bgs:latest -t bgs:${BITBUCKET_BUILD_NUMBER} .

- pipe: atlassian/aws-ecr-push-image:0.1.3
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: bgs
TAG: latest

- pipe: atlassian/aws-ecr-push-image:0.1.3
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: bgs
TAG: ${BITBUCKET_BUILD_NUMBER}

 

I believe you may be able to use the `TAGS` field with a space delimited set of tags:

```
TAGS: "tag1 tag2"
```

0 votes

I have the same error ✖ Validation errors: TAGS:- must be of string type.

Have this pipeline step. Help is much appreciated.

image: atlassian/default-image:2

pipelines:
default:
- step:
name: "Build and Push"
script:
# build the image
- docker build -t dockerdemo:${BITBUCKET_BUILD_NUMBER} .

# use the pipe to push the image to AWS ECR
- pipe: atlassian/aws-ecr-push-image:1.2.0
variables:
IMAGE_NAME: dockerdemo
TAG: ${BITBUCKET_BUILD_NUMBER}

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,060 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