无法通过Jenkins推送到Dockerhub

pipeline {
         agent any
         stages {

                 stage('Checkout') {
                 steps {
                     echo 'Retrieving Jenkinsfile from the github repository.'
                   checkout([$class: 'GitSCM',branches: [[name: '*/master']],doGenerateSubmoduleConfigurations: false,extensions: [[$class: 'LocalBranch',localBranch: 'dummy']],submoduleCfg: [],userRemoteConfigs: [[url: 'https://github.com/humblemetsuke/coursework_2']]])
                 }
                 }

        stage('Sonarqube') {
    environment {
        scannerHome = tool 'Sonarqube'
    }
    steps {
        withSonarqubeEnv('Sonarqube') {
            sh "${scannerHome}/bin/sonar-scanner"
        }
        timeout(time: 1,unit: 'HOURS') {
            waitForQualityGate abortPipeline: true
        }
    }
}

stage ('build docker image') {

steps {
echo 'Beginning to build the docker image.'

script {

 dockerImage= docker.build("coursework_2:${env.BUILD_ID}")

         }
}

}

stage ('push docker image to DockerHub') {

steps {
echo 'Beginning to push the built docker image to Dockerhub.'

script {

withDockerRegistry(credentialsId: 'e1984af9-1751-4825-883a-9194875c8f89',url: '') {


         }
         dockerImage.push()
}

}

}
}
}

我已附上我的Jenkins文件。每次运行它时,都会被告知:

denied: requested access to the resource is denied

我认为这可能是Docker登录问题。我故意输入了错误的凭据,并收到一条消息,提示用户名或密码不正确,因此能够消除该错误(并帮助确保登录成功不是误报)。但是,对于出了什么问题以及为什么我没有得到理想的结果,也就是将映像推送到Dockerhub,我一无所知。

h540969896 回答:无法通过Jenkins推送到Dockerhub

2019-12-11 21:48:55 [scrapy.spidermiddlewares.httperror] INFO: Ignoring response <400 https://passport.twitch.tv/login>: HTTP status code is not handled or not allowed 2019-12-11 21:48:55 [scrapy.core.engine] INFO: Closing spider (finished) 是否应放在dockerImage.push()的括号内?还是在上面的代码示例中意外地将其遗忘了?

,

在此Jenkins作业中,您是否使用2 Factor Authentication和/或您使用Personal Access Tokens作为Docker密码?

如果是这样,Jenkins可能会利用DockerHub API(而非Docker CLI)的某些方面,但有一些注意事项。请在此处查看我今天报道的一个特定案例:https://github.com/docker/hub-feedback/issues/1927

本文链接:https://www.f2er.com/2947446.html

大家都在问