Use private docker registry with Authentication in Jenkinsfile Use private docker registry with Authentication in Jenkinsfile docker docker

Use private docker registry with Authentication in Jenkinsfile


As specified in Using a custom registry, you can specify the credentials and registry url to use as such:

docker.withRegistry('https://registry.az1', 'credentials-id') {    ...}

You need to create a Jenkins credentials object which will contain the credentials for the repository and give it a name to replace credentials-id above.

Update:

For declarative pipelines, the syntax is as such:

agent {     docker {        image 'registry.az1:5043/maven-proto'        registryUrl 'https://registry.az1'        registryCredentialsId 'credentials-id'        args '-v /var/jenkins_home/.m2:/root/.m2'    }}