gpt4 book ai didi

Jenkins 亚马逊 ECR : no basic auth credentials

转载 作者:行者123 更新时间:2023-12-03 17:19:46 28 4
gpt4 key购买 nike

我无法使用 Jenkins Pipeline 将 ocker 图像推送到 Amazon ECR:我总是收到 no basic auth credentials :-(

这是我的设置:

  • Jenkins 2.46.2
  • Amazon ECR plugin 1.4
  • 我添加了 AWS 凭证 aws-jenkins到 Jenkins(在本地测试并成功推送到 AWS ECR)
  • 我已打印 /root/.dockercfg在我的 Jenkinsfile 中调试身份验证

  • Jenkins 文件:
    stage("Docker") {
    dir(path) {
    docker.build("my-image:latest")
    }
    docker.withRegistry("https://<my-aws-id>.dkr.ecr.eu-central-1.amazonaws.com", "ecr:eu-central-1:aws-jenkins") {
    sh "cat /root/.dockercfg" // debug
    docker.image("my-image:latest").push()
    }
    }

    日志:
    [Pipeline] withDockerRegistry
    Wrote authentication to /root/.dockercfg
    [Pipeline] {
    [Pipeline] sh
    [docker-emotion-compilers] Running shell script
    + cat /root/.dockercfg
    {"https://<my-aws-id>.dkr.ecr.eu-central-1.amazonaws.com": {
    "auth": "[...]",
    "email": "nobody@example.com"
    }}[Pipeline] sh
    [docker-emotion-compilers] Running shell script
    + docker tag --force=true my-image:latest <my-aws-id>.dkr.ecr.eu-central-1.amazonaws.com/my-image:latest
    Warning: '--force' is deprecated, it will be removed soon. See usage.
    [Pipeline] sh
    [docker-emotion-compilers] Running shell script
    + docker push <my-aws-id>.dkr.ecr.eu-central-1.amazonaws.com/my-image:latest
    The push refers to a repository [<my-aws-id>.dkr.ecr.eu-central-1.amazonaws.com/my-image]
    e30bf54e0f87: Preparing
    b9f2c30c0d28: Preparing
    5defc95691fd: Preparing
    295d6a056bfd: Preparing
    no basic auth credentials
    [Pipeline] }
    [Pipeline] // withDockerRegistry

    有任何想法吗?

    更新 (2017-05-23):
    这是 Jira 问题:
    https://issues.jenkins-ci.org/browse/JENKINS-44143

    最佳答案

    即使 docker.withRegistry 将在启动时登录到 ECR 并在完成时注销似乎是合乎逻辑的,但它并未执行。
    因此您必须安装 awscli 并在执行推送之前添加 ECR 登录命令。

    sh("eval \$(aws ecr get-login --no-include-email | sed 's|https://||')")



    http://www.tikalk.com/devops/ecr-in-pipeline/详细示例。

    关于 Jenkins 亚马逊 ECR : no basic auth credentials,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43733396/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com