Jenkins Pipeline docker.withRegistry() push 导致死循环

问题描述 投票:0回答:1

我设法在 kubernetes 上设置了 jenkins,在 kubernetes 上设置了 gitbucket。现在我正在尝试创建我自己的第一个 docker 文件,以便在 dockerhub 上上传。不幸的是,它在上传到 docker 时失败了。构建成功,但我无法管理如何将它上传到 dockerhub(私有存储库)。

詹金斯文件

def label = "${BUILD_TAG}"
 
podTemplate(label: label, containers: [
    containerTemplate(name: 'docker', image: 'docker:latest', command: 'cat', ttyEnabled: true)
],
volumes: [
    hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock')
]) {
    node(label) {
        def app
        def myRepo = checkout scm
        def gitCommit = myRepo.GIT_COMMIT
        def gitBranch = myRepo.GIT_BRANCH
        def shortGitCommit = "${gitCommit[0..10]}"
        def previousGitCommit = sh(script: "git rev-parse ${gitCommit}~", returnStdout: true)
        
        stage('Decommission Infrastructure') {
            container('kubectl') {
                echo "Decmomission..."
            }
        }
        
        stage('Build application') {
            container('docker') {
                app = docker.build("fasautomation/recon", ".")
            }
        }
        
        stage('Run unit tests') {
            container('docker') {
                app.inside {
                    sh 'echo "Test passed"'
                }
            }
        }

            stage('Docker publish') {
                container('docker') {
                    docker.withRegistry('https://registry.hub.docker.com', '<<jenkins store-credentials>>') {
                        echo "Pushing 1..."
                        // Push tagged version
                    app.push("${env.BUILD_NUMBER}")
                    echo "Pushing 2..."
                    // Push latest-tagged version
                    app.push("latest")
                    echo "Pushed!"
                    }
            }
            }
            
            stage('Deployment') {
            container('docker') {
                // Deploy to Kubernetes
                echo 'Deploying'
            }
            }
            
        stage('Provision Infrastructure') {
            container('kubectl') {
                echo 'Provision...'
            }
        }
    }
}

詹金斯日志

[...]
[Pipeline] stage (hide)
[Pipeline] { (Docker publish)
[Pipeline] container
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withDockerRegistry
Executing sh script inside container docker of pod jenkins-recon-master-116-0ksw8-f7779
Executing command: "docker" "login" "-u" "*****" "-p" ******** "https://index.docker.io/v1/" 
exit
<<endless loading symbol>>

有人知道如何在这里调试吗?凭据工作。不知道为什么日志中有出口而没有用于之后推送的日志...... :-(

docker jenkins jenkins-plugins docker-registry
1个回答
0
投票

您需要检查问题是否仍然存在Jenkins Docker commons 1.21

PR 86“docker 登录 - 从 stdin 获取密码” 已恢复(PR 108)。
它包括 JENKINS-69436“错误:无法从非 TTY 设备执行交互式登录”.

这意味着

docker.withRegistry
步骤现在有更好的机会(自2022年8月和docker commons 1.21)成功执行。

© www.soinside.com 2019 - 2024. All rights reserved.