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'
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'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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'.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.