docker - Jenkins:从奴隶推送到 ECR

标签 docker jenkins jenkins-plugins cloudbees amazon-ecr

我正在使用 spotify 的 maven 插件构建一个 docker 容器,然后尝试推送到 ecr。

使用 cloudbees Build and Publish 会发生这种情况管理使用 Amazon ECR 登录后的插件插件。

这对 Jenkins 大师来说就像一个魅力。 但在奴隶身上我得到:

no basic auth credentials

Build step 'Docker Build and Publish' marked build as failure

从奴隶的推送是否超出了 ECR 插件的范围,或者我错过了什么?

最佳答案

这里的答案对我的管道不起作用。我发现这个解决方案有效,而且也很干净:

withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'myCreds', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
    
    sh '''
    aws ecr get-login-password --region ${AWS_REGION} | docker login --username AWS --password-stdin ${REGISTRY}

    ..
    '''
}

此解决方案不需要 aws cli v2。

关于docker - Jenkins:从奴隶推送到 ECR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50254527/

相关文章:

logging - 日志级别作为 Docker GELF 日志记录驱动程序的字段

docker - 无法从 root 构建 docker

jenkins - 某些插件阻止 Jenkins 邮件工作

file-upload - Jenkins Parameterized Build上传文件并保存原文件名

git - Jenkins:git "Checking out Revision"后失败

Jenkins 创建从分支构建的构建作业 View

jenkins - 从 Jenkins 工作区外的文件中读取 DSL

scala - 无法使用flink在Scala中实例化用户功能

django - 使用 Django 在 Docker 上设置 RabbitMQ

Jenkins 管道: Should I clean workspace before unstash workspace on new node?