I'm trying to do some stuff on the pipeline but I thinking that I'm hitting a bug. I don't think that is a intended behaviour because it will kinda defeat the purpose of using docker or a docker worker.
My pipeline for test this.
pipeline {
agent any
stages {
stage('Build') {
agent {
docker {
image 'node'
label 'docker'
}
}
steps {
sh """ printf "%q%s" "/path with space" "/out-file.js" """
sh(script: """
#!/bin/bash
printf "%q%s" "/path with space" "/out-file.js"
""")
}
}
}
}
And I get this on the logs
+ printf %q%s /path with space /out-file.js
/user/builds/workspace/test@tmp/durable-6f010694/script.sh: 1: printf: %q: invalid directive
But if I run
$ docker run -it --rm node bash
root@c8e43eaefbae:/# printf "%q%s\n" "/path with space" "/out-file.js"
/path\ with\ space/out-file.js
root@c8e43eaefbae:/#
Works fine, the version of bash in the node container accepts the %q
but when running from jenkins I get this error.
It's like if jenkins is using his own version of bash instead of the version from the container.
Looking on the web I found this post talking about version.
But running this command dpkg -s coreutils | grep -i version
on the pipeline and on the docker run it gives the same version 8.26-3
...
sh "dpkg -s coreutils | grep -i version"
sh "npm --version"
sh "/bin/bash --version"
...
jenkins logs:
[Pipeline] {
[Pipeline] sh
+ + grepdpkg -i version -s coreutils
Version: 8.26-3
[Pipeline] sh
+ npm --version
7.0.3
+ /bin/bash --version
GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
or
root@c8e43eaefbae:/# dpkg -s coreutils | grep -i version
Version: 8.26-3
root@c8e43eaefbae:/#
root@c8e43eaefbae:/# /bin/bash --version
GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
Before open a issue on jenkins I would like to know if this is the intended behaviour, I'm doing something wrong or if it's really a bug.
Jenkins 2.249.2
Docker Desktop for MAC 2.4.0.0 (48506)
engine 19.03.13
compose 1.27.4
Running compose with a jenkins (jenkins/jenkins:lts), a nginx (nginx:latest) to route a pretty domain name and docker (docker:stable) as worker