Image not found: 404 Client Error: Not Found: aws-ecr-push-image atlassian pipeline
Asked Answered
U

2

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.

Ultan answered 21/1, 2020 at 18:43 Comment(0)
L
6

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'
Lora answered 22/1, 2020 at 13:6 Comment(0)
O
1

The spec changed for aws-ecr-push-image 2.0 so the accepted answer no longer applies to the latest version. Spec note: major: Breaking change: Refactored the logic of how pipe push images. Now you have to build images with all tags you want to push to ecr before pipe call.

The updated code will look something like this:

    name: Updating docker image
    script:
      - docker build -t image-test:${BITBUCKET_TAG} -t image-test .
      - pipe: atlassian/aws-ecr-push-image:2.3.0
        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'
Overlarge answered 31/1 at 22:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.