I have a java service that I am trying to create a pipeline to build, create a docker image, tag and push to my ECR.
Steps so far:
Created IAM account with AmazonEC2ContainerRegistryPowerUser privileges.
Created the following repository variables in Bitbucket:
- AWS_REGISTRY_URL
- AWS_DEFAULT_REGION
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
I have the following bitbucket-pipelines.yml:
image: openjdk:8
pipelines:
default:
- step:
caches:
- gradle
script:
- bash ./gradlew build -x test
branches:
develop:
- step:
image: openjdk:8
services:
- docker
script:
- docker version
- echo "This script runs only on commit to the develop branch."
- bash ./gradlew build -x test
# Login to AWS
# - export LOGIN=$(aws ecr get-login --no-include-email --region us-west-1)
# - $LOGIN
- eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email)
# build docker image
- docker build -t my-image .
# tag and push docker images to ECR
- docker tag icverify-gateway:latest xxxxxxxxxxx.amazonaws.com/my-image:qa
- docker push xxxxxxxxxxx.amazonaws.com/my-image:qa
# register the ECS task definition and capture the version
- export IMAGE_NAME=xxxxxxxxxxx.amazonaws.com/my-image:qa
- export TASK_VERSION=$(aws ecs register-task-definition --family my-image -- container-definitions "[]")
I then get the following on code commit:
<span>+ docker push xxxxxxxxxxx.amazonaws.com/my-image:qa<a href="http://767640272519.dkr.ecr.us-west-1.amazonaws.com/icverify-gateway:qa" target="_blank" rel="noopener nofollow noreferrer"><br></a></span><span>The push refers to repository [xxxxxxxxxxx.amazonaws.com/my-image]<br></span><span>ac079aa23bfa: Preparing</span><span><br>ceaf9e1ebef5: Preparing<br></span><span>9b9b7f3d56a0: Preparing<br></span><span>f1b5933fe4b5: Preparing<br></span><span>no basic auth credentials</span>