2

我有这个:

docker login -u AWS --password-stdin https://aws_account_id.dkr.ecr.us-east-1.amazonaws.com
Error: Cannot perform an interactive login from a non TTY device
Build step 'Execute shell' marked build as failure

我们如何在 Jenkins 服务器上运行 docker login (或等效的)?

我能够通过使用解决这个问题:

eval "$(aws ecr get-login --no-include-email --region ${region} --profile ${profile})"

但是在我尝试运行后出现此错误docker push

没有基本的身份验证凭据

4

2 回答 2

9

正如@matt-schuchard 提到的,您可以使用Docker Pipeline Plugin。就我而言,我使用了docker.withRegistry([...]). 在下面找到一个完整的例子:

node {
    def app

    stage('Clone repository') {
        /* Clone your repo */

    }

    stage('Build image') {
        /* Build your image */

        app = docker.build("<image name>")
    }

    stage('Push image') {
        /* Push image using withRegistry. */
        docker.withRegistry('<your docker registry>', 'docker-private-credentials') {
            app.push("${env.BUILD_NUMBER}")
            app.push("latest")
        }
    }
}
于 2019-04-29T23:25:57.793 回答
0

使用 ecr:us-east-1,在我的情况下使用 ecr 作为前缀。我浪费了很多时间来调试这个。我希望他们更新插件本身的文档。https://blog.mikesir87.io/2016/04/pushing-to-ecr-using-jenkins-pipeline-plugin/中明确提到了这一点,但我错过了。

于 2019-06-14T05:00:31.690 回答