无法推送图像 - 失败 "no basic auth credentials"

Can't push image - fails with "no basic auth credentials"

GitLab CICD Pipeline 在开发阶段失败,成功构建和标记但在推送引用 Amazon 存储库 (ECR) 时失败。

*6be90f1a2d3f: Preparing
no basic auth credentials
Cleaning up project directory and file based variables 
ERROR: Job failed: exit code 1*

您需要检查 GitLab 作业机密的价值:

  • AWS_REGISTRY_URL
  • AWS_DEFAULT_REGION
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

this thread 一样(对于 bitBucket 管道,但可以应用于 GitLab 管道),您的管道应包含一个登录步骤

eval $(aws ecr get-login --no-include-email --region YOUR-REGION-HERE | sed 's|https://||')

make sure to change the region from YOUR-REGION-HERE to the one you are trying to deploy to. For me this is --region ap-southeast-2.