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

dockerfile: ARG in FROM breaks docker inspect

    Details

    • Similar Issues:

      Description

      Please note that there is already an issue with a very similar name regarding the docker-workflow plugin here: https://issues.jenkins-ci.org/browse/JENKINS-46105

      The issue actually has been fixed already at the docker-workflow plugin, but the pipeline-model-definition-plugin fails to take advantage of that.

      The issue in a nutshell:

      I have this Dockerfile (excerpt):

      ARG VERSION=latest
      FROM repo-vp.development.ems:5000/emsys-adoptopenjdk11:${VERSION}
      

       

      This is part of my declarative Jenkinsfile:

              stage('Build') {
                agent { 
                  dockerfile {
                    filename 'Dockerfile'
                    additionalBuildArgs "--build-arg VERSION=jdk-11.0.2.9"
                    reuseNode true
                  }
                }
                steps {
                  (...)
                }
              }
      

       

      This results in a failed build with the following error log:

      java.io.IOException: Cannot retrieve .Id from 'docker inspect repo-vp.development.ems:5000/emsys-adoptopenjdk11:${VERSION}'
      	at org.jenkinsci.plugins.docker.workflow.client.DockerClient.inspectRequiredField(DockerClient.java:220)
      	at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:133)
      	at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:85)
      	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
      	at hudson.security.ACL.impersonate(ACL.java:290)
      	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Finished: FAILURE
      

      This has already been fixed by the docker-workflow plugin (see JENKINS-46105), but "pipeline-model-definition" has yet to take advantage of that.

      Please see this line in your plugin: https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/7502d14aa4db891302abf48a2c7de7c9ced97f95/pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfileScript.groovy#L83

      As you can see, you don't pass the new parameter "buildArgs" to the instance of `dockerFingerprintFrom`. See the setter here: https://github.com/jenkinsci/docker-workflow-plugin/blob/dbeb7cf23961fdb5cbc495e8067bd42c56dcdfc5/src/main/java/org/jenkinsci/plugins/docker/workflow/FromFingerprintStep.java#L81

      If you just pass the build-args to this step, the issue should be resolved.

       

        Attachments

          Activity

          Hide
          dwightguth Dwight Guth added a comment -

          This has been fixed in my pull request: https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/311

          It would be nice to see some action on this PR so I don't have to keep relying on a manually-built HPI file for this plugin.

          Show
          dwightguth Dwight Guth added a comment - This has been fixed in my pull request: https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/311 It would be nice to see some action on this PR so I don't have to keep relying on a manually-built HPI file for this plugin.

            People

            • Assignee:
              abayer Andrew Bayer
              Reporter:
              christianciach Christian Ciach
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: