-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
docker-workflow 1.17, pipeline-model-definition 1.3.4.1, Jenkins 2.165
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.
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.