Hello,
I'm preparing CI/CD using AWS CodePipeline. Unfortunatelly I have an error during build stage.
Below there is content of my buildspec.yml file, where:
AWS_DEFAULT_REGION = eu-central-1
CONTAINER_NAME=cicd-1-app
REPOSITORY_URI = <ACCOUNT_ID>.dkr.ecr.eu-central-1.amazonaws.com/cicd-1-app
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws --version
- TAG="$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
- IMAGE_URI=${REPOSITORY_URI}:${TAG}
build:
commands:
- echo Build started on `date`
- echo $IMAGE_URI
- mvn clean package -Ddockerfile.skip
- docker build --tag $IMAGE_URI .
post_build:
commands:
- printenv
- echo Build completed on `date`
- echo $(docker images)
- echo Pushing docker image
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin <ACCOUNT_ID>.dkr.ecr.eu-central-1.amazonaws.com
- docker push $IMAGE_URI
- echo push completed
- printf '[{"name":"%s","imageUri":"%s"}]' $CONTAINER_NAME $IMAGE_URI > imagedefinitions.json
artifacts:
files:
- imagedefinitions.json
I got error:
[Container] 2022/01/06 19:57:36 Running command aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin <ACCOUNT_ID>.dkr.ecr.eu-central-1.amazonaws.com
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[Container] 2022/01/06 19:57:37 Running command docker push $IMAGE_URI
The push refers to repository [<ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/cicd-1-app]
37256fb2fd27: Preparing
fe6c1ddaab26: Preparing
d4dfab969171: Preparing
no basic auth credentials
[Container] 2022/01/06 19:57:37 Command did not exit successfully docker push $IMAGE_URI exit status 1
[Container] 2022/01/06 19:57:37 Phase complete: POST_BUILD State: FAILED
[Container] 2022/01/06 19:57:37 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: docker push $IMAGE_URI. Reason: exit status 1
Even docker logged in successfully there is "no basic auth credentials" error.
Do you know what could be a problem?
Best regards.
You're totally right. Silly mistake. I wrote that REPOSITORY_URI is
while in my environments it was:
I forgot to update this value. Thanks for your tip. Best regards