• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • docker-workflow-plugin
    • None
    • docker 17.05+
    • docker-workflow 1.18

      Taking advantage of https://github.com/moby/moby/issues/18119 is not supported by docker.build.

      Minimal docker file 

      ARG TAG
      FROM image:${TAG}
      

       
      Docker build

      docker.build("image_name", "--build-arg TAG=${package_version} -f Dockerfile .")
      

       

      Stacktrace

      java.io.IOException: Cannot retrieve .Id from 'docker inspectimage:${TAG}'
              at org.jenkinsci.plugins.docker.workflow.client.DockerClient.inspectRequiredField(DockerClient.java:203)
              at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:119)
              at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:75)
              at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
              at hudson.security.ACL.impersonate(ACL.java:260)
              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:1142)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
              at java.lang.Thread.run(Thread.java:745)
      

          [JENKINS-46105] Docker 17.05 ARG in FROM breaks docker inspect

          Andrew Bayer added a comment -

          Will be in next release - 1.15.

          Andrew Bayer added a comment - Will be in next release - 1.15.

          great. is there any roadmap when 1.15 will be released?

          Andrzej Dopierała added a comment - great. is there any roadmap when 1.15 will be released?

          Peter Grayson added a comment -

          Using the repair in version 1.15, this works:

          docker.build(..., "--build-arg IMAGE=x")

          But this does not (note the = after --build-arg):

          docker.build(..., "--build-arg=IMAGE=x")

          The failure signature is the same as before the repair:

          java.io.IOException: Cannot retrieve .Id from 'docker inspect$IMAGE'

          So it appears that the parsing done by the plugin does not comprehend the --build-arg= form which is valid when running docker build on the command line.

          Peter Grayson added a comment - Using the repair in version 1.15, this works: docker.build(..., "--build-arg IMAGE=x") But this does not (note the = after --build-arg ): docker.build(..., "--build-arg=IMAGE=x") The failure signature is the same as before the repair: java.io.IOException: Cannot retrieve .Id from 'docker inspect$IMAGE' So it appears that the parsing done by the plugin does not comprehend the --build-arg= form which is valid when running docker build on the command line.

          Christoph Linder added a comment - jpgrayson : Confirmed and fixed in PR  https://github.com/jenkinsci/docker-workflow-plugin/pull/136

          This seems to be a dup of JENKINS-44836?

          Joshua Hoblitt added a comment - This seems to be a dup of JENKINS-44836 ?

          This is also failing for me when the ARG has a default value. Ie., there is no --build-arg to parse.

          ARG FOO=7
          FROM centos:${FOO}
          

          Joshua Hoblitt added a comment - This is also failing for me when the ARG has a default value. Ie., there is no --build-arg to parse. ARG FOO=7 FROM centos:${FOO}

          Probably also a dup of JENKINS-31507.

          I will repeat my comment here:

           

          Dockerfile:

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

          Jenkinsfile (declarative):

                    agent { 
                      dockerfile {
                        filename 'Dockerfile'
                        additionalBuildArgs "--build-arg VERSION=${env.JDK_VERSION}"
                        reuseNode true
                      }
                    }
          

          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
          
          

          I haven't found a workaround yet.

          Christian Ciach added a comment - Probably also a dup of JENKINS-31507 . I will repeat my comment here:   Dockerfile: ARG VERSION=latest FROM repo-vp.development.ems:5000/emsys-adoptopenjdk11:$VERSION Jenkinsfile (declarative): agent { dockerfile { filename 'Dockerfile' additionalBuildArgs "--build-arg VERSION=${env.JDK_VERSION}" reuseNode true } } 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 I haven't found a workaround yet.

          I am confused: According to the comments here my example of the previous comment should work since docker-workflow 1.15. I am currently using 1.17, but it still doesn't work.

          Christian Ciach added a comment - I am confused: According to the comments here my example of the previous comment should work since docker-workflow 1.15. I am currently using 1.17, but it still doesn't work.

          EDIT:

          It looks like my issue is actually a bug in the "pipeline-model-definition-plugin". The plugin creates an instance of `FromFingerprintStep` (a class of this plugin), but fails to set the build-args (`FromFingerprintStep.setBuildArgs(..)`). See here:

          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

          Christian Ciach added a comment - EDIT: It looks like my issue is actually a bug in the "pipeline-model-definition-plugin". The plugin creates an instance of `FromFingerprintStep` (a class of this plugin), but fails to set the build-args (`FromFingerprintStep.setBuildArgs(..)`). See here: 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

          Devin Nusbaum added a comment -

          The lingering issue with ARGs that specified a default value was fixed in version 1.18 of the Docker Pipeline plugin. See the release notes on the plugin's wiki page for details.

          Devin Nusbaum added a comment - The lingering issue with ARGs that specified a default value was fixed in version 1.18 of the Docker Pipeline plugin. See the release notes on the plugin's wiki page for details.

            abayer Andrew Bayer
            rpocase Robby Pocase
            Votes:
            9 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: