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

Docker inspect failing on named multi-stage builds

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • docker-workflow-plugin
    • None
    • Debian Jessie x64
      Docker Pipeline 1.11
      Jenkins ver. 2.46.3
      Docker version 17.05.0-ce, build 89658be
    • docker-workflow 1.19

      When using named stages in a multistage build as in the example below, the Jenkins pipeline will fail with the following message right after the build has finished.

      <SNIP>
      Successfully built b59ee5bc6b07
      Successfully tagged bytesheep/odr-dabmux:latest
      [Pipeline] dockerFingerprintFrom
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      java.io.IOException: Cannot retrieve .Id from 'docker inspectalpine:3.6 AS builder'
          at org.jenkinsci.plugins.docker.workflow.client.DockerClient.inspectRequiredField(DockerClient.java:193)
          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:748)
      Finished: FAILURE

       

      Dockerfile

      #
      # Build environment
      #
      FROM alpine:3.6 AS builder
      
      <SNIP>
      
      #
      # Create final container
      #
      FROM alpine:3.6
      
      <SNIP>
      
      # Copy artifacts from builder
      COPY --from=builder /usr/local .
      

       

      There is a workaround to this issue by removing the names and using the build numbers instead. example:

      FROM alpine:3.6
      
      <SNIP>
      
      FROM alpine:3.6
      
      COPY --from=0 /usr/local .

       

      Looking at the related source at #100, it seems the code determains the image name looking at FROM and taking everything until EOL. Which would include 'AS buildname'.

      At a glance it also looks like the code will take the first stage for fingerprinting instead of the final stage (which is the resulting image).

            esmalling Eric Smalling
            m4rcu5 Marcus van Dam
            Votes:
            42 Vote for this issue
            Watchers:
            54 Start watching this issue

              Created:
              Updated:
              Resolved: