5

I'm using the Atlassian pipeline to build and push the docker image to AWS ECR but build is getting tear down with following message.

INFO: Executing the aws-ecr-push-image pipe...

INFO: Found credentials in environment variables.

INFO: Successfully logged in to https://XXXXXXX.dkr.ecr.us-east-1.amazonaws.com

✖ Image not found: 404 Client Error: Not Found ("no such image: image-test: No such image: image-test:latest")

Here is my bitbucket-pipelines.yml code:

    - step:
        name: docker build running
        services: 
          - docker
        script: 
          - docker build -t image-test .
        artifacts:
          - Image_Test.zip  
    - step:
        name: Updating docker image
        script:
          - pipe: atlassian/aws-ecr-push-image:1.0.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-test
              TAGS: '${BITBUCKET_TAG} latest'

I confirm that this image exists in my ECR repositories.

Saurabh Sharma
  • 463
  • 2
  • 7
  • 20

1 Answers1

5

Docker images do not persist between pipeline steps. You have to build and push the image in the same step, for example:

- step:
    name: Updating docker image
    script:
      - docker build -t image-test .
      - pipe: atlassian/aws-ecr-push-image:1.0.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-test
          TAGS: '${BITBUCKET_TAG} latest'
Alexander Zhukov
  • 4,357
  • 1
  • 20
  • 31