gpt4 book ai didi

jenkins-pipeline - 来自 AWS ECR 的 Jenkins 管道 Docker 代理

转载 作者:行者123 更新时间:2023-12-01 00:11:43 30 4
gpt4 key购买 nike

我需要在 Docker 中作为代理执行 Jenkins 管道,

Docker 镜像位于 AWS ECR 中,

如何通过 AWS ECR 进行身份验证以为代理提取镜像?

最佳答案

agent {
docker {
alwaysPull true
image '<aws-account-Id>.dkr.ecr.us-west-2.amazonaws.com/<ecr-repo>:<tag>'
registryUrl 'https://<aws-account-Id>.dkr.ecr.us-west-2.amazonaws.com'
registryCredentialsId 'ecr:us-west-2:<Jenkins Credential ID>'
}
}

要首先在 jenkins 中使用来自 AWS ECR 存储库的图像作为代理,您需要添加种类凭证 AWS Credentials .
现在只需将上面的代码用于管道代码中的代理块。
确保更换
  • <aws-account>带有 AWS 账户 ID。
  • <ecr-repo>使用 ECR 存储库名称
  • <tag>带有您要使用的 ECR 图像标签。
  • <Jenkins Credential ID>使用在 Jenkins 中保存凭据时获得的 Jenkins 凭据 ID。
  • us-west-2替换为您的 ecr repo 区域

  • 您可以使用 https://<jenkins.url>/directive-generator/为您生成此代码。

    关于jenkins-pipeline - 来自 AWS ECR 的 Jenkins 管道 Docker 代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58094119/

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