| When using the RedHat Docker distribution, the dir step fails. Given this example pipeline :
pipeline {
agent {
docker {
image 'alpine'
}
}
stages {
stage('Test') {
steps {
dir('test') {
sh 'pwd'
}
}
}
}
}
After a couple of minutes doing nothing in the dir step, the build finally fails with this error :
[Pipeline] dir
Running in /home/jenkins/agent/workspace/test/test
[Pipeline] {
[Pipeline] sh
process apparently never started in /home/jenkins/agent/workspace/test/test@tmp/durable-e1730f3c
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
[Pipeline] // dir
When running Jenkins with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true as suggested, it outputs more info :
[Pipeline] dir
Running in /home/jenkins/agent/workspace/test/test
[Pipeline] {
[Pipeline] sh
"--workdir" requires API version 1.35, but the Docker daemon API version is 1.26
process apparently never started in /home/jenkins/agent/workspace/test/test@tmp/durable-af2c36e9
[Pipeline] }
[Pipeline] // dir
I guess the dir step has a specific behavior when running on a Docker agent and tries to use --workdir option to change directory. Unfortunately, this option is not available with Docker API < 1.35, which is the case with the RedHat distribution. IMHO, the dir step should be agnostic of whether or not the step is running in a Docker agent. I didn't find the piece of code that is responsible for this behavior. I would be glad to submit a PR as soon as someone helps me find it. |