-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
Jenkins 2.176.2, linux master, agent on macOS 10.13.6
When running a pipeline script like this:
node('docker') { def CURRENT_VERSION def builtImage stage('Clone repository') { checkout scm } stage('Output version') { CURRENT_VERSION = sh (returnStdout: true, script: 'python "${SCRIPTS}/version.py" show all' ).trim() } stage('Build image') { builtImage = docker.build("${DOCKER_IMAGE}:${CURRENT_VERSION}", ".") } stage('Push image') { docker.withRegistry("${DOCKER_REGISTRY}", "${DOCKER_CREDENTIALS}") { builtImage.push() } } }
The build fails on the docker.withRegistry stage with error docker command not found:
Successfully built 8e4939ceb3f6 Successfully tagged org/project:2.5.2.112-1-g3cab587 [Pipeline] dockerFingerprintFrom [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:247) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to mini-01 at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743) at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357) at hudson.remoting.Channel.call(Channel.java:957) at hudson.Launcher$RemoteLauncher.launch(Launcher.java:1060) at hudson.Launcher$ProcStarter.start(Launcher.java:455) at org.jenkinsci.plugins.docker.workflow.client.DockerClient.launch(DockerClient.java:296) at org.jenkinsci.plugins.docker.workflow.client.DockerClient.launch(DockerClient.java:277) at org.jenkinsci.plugins.docker.workflow.client.DockerClient.launch(DockerClient.java:274) at org.jenkinsci.plugins.docker.workflow.client.DockerClient.inspect(DockerClient.java:198) at org.jenkinsci.plugins.docker.workflow.client.DockerClient.inspectRequiredField(DockerClient.java:218) at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:110) at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:84) 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) Caused: java.io.IOException: Cannot run program "docker": error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at hudson.Proc$LocalProc.<init>(Proc.java:250) at hudson.Proc$LocalProc.<init>(Proc.java:219) at hudson.Launcher$LocalLauncher.launch(Launcher.java:937) at hudson.Launcher$ProcStarter.start(Launcher.java:455) at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1319) at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1272) at hudson.remoting.UserRequest.perform(UserRequest.java:212) at hudson.remoting.UserRequest.perform(UserRequest.java:54) at hudson.remoting.Request$2.run(Request.java:369) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) 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 install location on the slave for the docker binary is in /usr/local/bin, which is not by default in PATH.
It is set as an extra variable on the executor configuration by setting an environment variable named PATH+LOCALBIN with value /usr/local/bin.
I managed to override the problem by building a custom version of the plugin, setting the docker command with a hardcoded path in DockerTool.java:58, but it's not a general solution.