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,我一无所知。