• 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

          Hello,

          Same situation here:

          java.io.IOException: Cannot retrieve .Id from 'docker inspectnode:${NODE_VERSION}'
          	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:1149)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          	at java.lang.Thread.run(Thread.java:748)
          Finished: FAILURE
          

          The workflow can't handle ARG variable properly here:

          ARG NODE_VERSION=8.5
          FROM node:${NODE_VERSION}

          Grzegorz Szczudlik added a comment - Hello, Same situation here: java.io.IOException: Cannot retrieve .Id from 'docker inspectnode:${NODE_VERSION}' 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:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:748) Finished: FAILURE The workflow can't handle ARG variable properly here: ARG NODE_VERSION=8.5 FROM node:${NODE_VERSION}

          FromFingerprintStep does not account for placeholders.

           

          I implemented a fix:

          https://github.com/jenkinsci/docker-workflow-plugin/pull/118

           

          Christoph Linder added a comment - FromFingerprintStep does not account for placeholders.   I implemented a fix: https://github.com/jenkinsci/docker-workflow-plugin/pull/118  

          Code changed in jenkins
          User: Christoph Linder
          Path:
          src/main/java/org/jenkinsci/plugins/docker/workflow/DockerUtils.java
          src/main/java/org/jenkinsci/plugins/docker/workflow/FromFingerprintStep.java
          src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy
          src/test/java/org/jenkinsci/plugins/docker/workflow/FromFingerprintStepTest.java
          http://jenkins-ci.org/commit/docker-workflow-plugin/35caf3faddf931dc49ee0182d4161380b2a541cb
          Log:
          JENKINS-46105 Docker 17.05 ARG in FROM breaks docker inspect

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christoph Linder Path: src/main/java/org/jenkinsci/plugins/docker/workflow/DockerUtils.java src/main/java/org/jenkinsci/plugins/docker/workflow/FromFingerprintStep.java src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy src/test/java/org/jenkinsci/plugins/docker/workflow/FromFingerprintStepTest.java http://jenkins-ci.org/commit/docker-workflow-plugin/35caf3faddf931dc49ee0182d4161380b2a541cb Log: JENKINS-46105 Docker 17.05 ARG in FROM breaks docker inspect

          Code changed in jenkins
          User: Christoph Linder
          Path:
          .editorconfig
          src/main/java/org/jenkinsci/plugins/docker/workflow/DockerUtils.java
          src/test/java/org/jenkinsci/plugins/docker/workflow/FromFingerprintStepTest.java
          http://jenkins-ci.org/commit/docker-workflow-plugin/c7ceba43900d3160eab695167a5588ad10f7e9c5
          Log:
          JENKINS-46105 Docker 17.05 ARG in FROM breaks docker inspect (adhere to coding standards)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christoph Linder Path: .editorconfig src/main/java/org/jenkinsci/plugins/docker/workflow/DockerUtils.java src/test/java/org/jenkinsci/plugins/docker/workflow/FromFingerprintStepTest.java http://jenkins-ci.org/commit/docker-workflow-plugin/c7ceba43900d3160eab695167a5588ad10f7e9c5 Log: JENKINS-46105 Docker 17.05 ARG in FROM breaks docker inspect (adhere to coding standards)

          Code changed in jenkins
          User: Christoph Linder
          Path:
          src/main/java/org/jenkinsci/plugins/docker/workflow/DockerUtils.java
          http://jenkins-ci.org/commit/docker-workflow-plugin/b07130ba576034a8731c436b85d5b087ceaed62e
          Log:
          JENKINS-46105 Docker 17.05 ARG in FROM breaks docker inspect (Jenkins fail)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christoph Linder Path: src/main/java/org/jenkinsci/plugins/docker/workflow/DockerUtils.java http://jenkins-ci.org/commit/docker-workflow-plugin/b07130ba576034a8731c436b85d5b087ceaed62e Log: JENKINS-46105 Docker 17.05 ARG in FROM breaks docker inspect (Jenkins fail)

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          .editorconfig
          src/main/java/org/jenkinsci/plugins/docker/workflow/DockerUtils.java
          src/main/java/org/jenkinsci/plugins/docker/workflow/FromFingerprintStep.java
          src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy
          src/test/java/org/jenkinsci/plugins/docker/workflow/FromFingerprintStepTest.java
          http://jenkins-ci.org/commit/docker-workflow-plugin/0e95d9409eb7d219dd9f4f37383c5321c630b889
          Log:
          Merge pull request #118 from HonoluluHenk/fix-dynamic-FROM-in-build-fingerprinting

          JENKINS-46105 Docker 17.05 ARG in FROM breaks docker inspect

          Compare: https://github.com/jenkinsci/docker-workflow-plugin/compare/8a8644434925...0e95d9409eb7

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: .editorconfig src/main/java/org/jenkinsci/plugins/docker/workflow/DockerUtils.java src/main/java/org/jenkinsci/plugins/docker/workflow/FromFingerprintStep.java src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy src/test/java/org/jenkinsci/plugins/docker/workflow/FromFingerprintStepTest.java http://jenkins-ci.org/commit/docker-workflow-plugin/0e95d9409eb7d219dd9f4f37383c5321c630b889 Log: Merge pull request #118 from HonoluluHenk/fix-dynamic-FROM-in-build-fingerprinting JENKINS-46105 Docker 17.05 ARG in FROM breaks docker inspect Compare: https://github.com/jenkinsci/docker-workflow-plugin/compare/8a8644434925...0e95d9409eb7

          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: