我正在使用 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/