-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Minor
-
Component/s: pipeline, pipeline-model-definition-plugin
I created a Multibranch pipeline job and configure docker registry credentials in the Pipeline Model Definition section (see attachment)
Jenkins file below:
Â
pipeline {
agent any
stages {
stage('Build') {
steps {
script {
def image = docker.build "***.com/docker-build-demo:${env.BUILD_TAG}"
image.push()
image.push('latest')
}
}
}
}
}
And pipeline failed on docker push step:
Â
Â
+ docker push ***.com/docker-build-demo:jenkins-docker-build-demo-master-4 The push refers to repository [***.com/docker-build-demo] ebf12965380b: Preparing denied: requested access to the resource is denied script returned exit code 1
Â
I can do workaround like this to make the pipeline success but that makes the Jenkinsfile bind to specific jenkins configuration and cannot be run everywhere:
Â
Â
pipeline {
agent any
stages {
stage('Build') {
steps {
script {
docker.withRegistry('https://***.com', 'credential-id') {
def image = docker.build "***.com/docker-build-demo:${env.BUILD_TAG}"
image.push()
image.push('latest')
}
}
}
}
}
}
Â