When using an agent directive in Declarative Pipeline there is no way to specify the Docker Registry to use. In Scripted Pipline this is available via the withRegistry wrapper

      docker.withRegistry('https://docker.mycorp.com/', 'docker-login') {
        git '…'
        docker.build('myapp').push('latest')
      }
      

      For Declarative we should allow admins to create a default registry to be used by all Pipelines at the master level or the folder level. We should also allow a specific registry setting in the language itself via the agent directive.

          [JENKINS-39684] Use docker images from private registry

          Peter Leibiger added a comment - michaelneale I already commented on that PR regarding this issue: https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/73#issuecomment-267946020

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - Preliminary PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/86

          I can probably test this sometime this week.

          Peter Leibiger added a comment - I can probably test this sometime this week.

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipeline.java
          pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfile.java
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfileScript.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineScript.groovy
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/d76175b8b7d302fe46cccfda2bca36eb9f857974
          Log:
          [FIXED JENKINS-39684] Add registryUrl and registryCredentialsId

          Added to both docker and dockerfile agent types. Not sure how to test
          this, honestly.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipeline.java pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfile.java pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfileScript.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineScript.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/d76175b8b7d302fe46cccfda2bca36eb9f857974 Log: [FIXED JENKINS-39684] Add registryUrl and registryCredentialsId Added to both docker and dockerfile agent types. Not sure how to test this, honestly.

          Works for me.

          Peter Leibiger added a comment - Works for me.

          Tom Bamford added a comment - - edited

          For the benefit of anyone else who discovers this in future wondering what the syntax should actually look like altogether, example given below:

           

          agent {
            docker {
              label 'docker'
              image 'myregistry.com/node:7.10.0'
              registryUrl 'https://myregistry.com/'
              registryCredentialsId 'myPredefinedCredentialsInJenkins'
            }
          }
          

          Tom Bamford added a comment - - edited For the benefit of anyone else who discovers this in future wondering what the syntax should actually look like altogether, example given below:   agent {   docker {     label 'docker'     image 'myregistry.com/node:7.10.0'     registryUrl 'https: //myregistry.com/'     registryCredentialsId 'myPredefinedCredentialsInJenkins'   } }

          Cyril Jouve added a comment -

          Cyril Jouve added a comment - Hello, this is a great feature but I could not find documentation/exemple. I looked here: https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki https://jenkins.io/doc/ https://www.google.fr/search?q=jenkins+pipeline+additionalBuildArgs  

          Jordan Raub added a comment - - edited

          The resolved dependent issue (JENKINS-40524) does add the registryUrl and registryCredentialsId, but what is the mechanism to push a tag into the registry upon success?

          Jordan Raub added a comment - - edited The resolved dependent issue ( JENKINS-40524 ) does add the registryUrl and registryCredentialsId, but what is the mechanism to push a tag into the registry upon success?

          Andrew Bayer added a comment -

          jraub_switch Feel free to open a new issue for that.

          Andrew Bayer added a comment - jraub_switch Feel free to open a new issue for that.

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.

            abayer Andrew Bayer
            hrmpw Patrick Wolf
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: