Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-46277

Latest docker image is not pulled when used within stage

XMLWordPrintable

      When a docker image is used as an agent at the pipeline level, `image.pull()` is called automatically to check for a newer version. E.g.:

      pipeline {
        agent { docker 'microsoft/dotnet' }
        stages {
          stage('x') {
            steps {
              sh '...'
            }
          }
        }
      }
      

      However, when a docker image is used as an agent at the stage level, `image.pull()` is never called, so potentially old images are used instead.E.g.:

      pipeline {
        agent none
        stages {
          stage('x') {
            agent { docker 'microsoft/dotnet' }
            steps {
              sh '...'
            }
          }
        }
      }
      

      Is it possible to automatically call `image.pull()` as well, or at least provide an option flag to state you want this behaviour?

      I believe the code that affects this is: https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/824b3b7a96cc9d4fc6fc636caccaed3d39343cfd/pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineScript.groovy#L42

            abayer Andrew Bayer
            chris5287 Chris Stylianou
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: