-
Type:
Bug
-
Resolution: Not A Defect
-
Priority:
Major
-
Environment:Jenkins 2.164.2
Docker Pipeline Plugin 1.18
Pipeline Plugin 2.6
Blue Ocean Plugin 1.14.0
With the following pipeline:
pipeline{
agent none
stages{
stage('deploy') {
agent {
docker {
image 'alpine:latest'
}
}
steps {
sh """
#!/bin/sh
echo foo
"""
}
}
}
}
I get the following output:
[Pipeline] Start of Pipeline (hide)
[Pipeline] stage
[Pipeline] { (deploy)
[Pipeline] node
Running on Auto-launched Jenkins NextGen build slave (i-XXX) in /home/jenkins/workspace/XXX
[Pipeline] {
[Pipeline] checkout
Git checkout logs...
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ docker inspect -f . alpine:latest
Error: No such object: alpine:latest
[Pipeline] sh
+ docker pull alpine:latest
latest: Pulling from library/alpine
bdf0201b3a05: Already exists
Digest: sha256:28ef97b8686a0b5399129e9b763d5b7e5ff03576aa5580d6f4182a49c5fe1913
Status: Downloaded newer image for alpine:latest
[Pipeline] withDockerContainer
Auto-launched Jenkins XXX build slave (i-XXX) does not seem to be running inside a container
$ docker run -t -d -u 5130:5130
-w /home/jenkins/workspace/XXX
-v /home/jenkins/workspace/XXX:/home/jenkins/workspace/XXX:rw,z
-v /home/jenkins/workspace/XXX@tmp:/home/jenkins/workspace/XXX@tmp:rw,z
-e ******** -e ******** -e ******** -e ******** -e ******** -e ********
-e ******** -e ******** -e ******** -e ******** -e ******** -e ********
-e ******** -e ******** -e ******** -e ******** -e ******** -e ********
-e ******** -e ******** -e ******** -e ******** -e ******** -e ********
-e ******** -e ******** -e ******** -e ******** -e ******** -e ********
alpine:latest cat
[Pipeline] {
[Pipeline] sh
$ docker top 9d50ea59f9db9cc74075029184bf24c1bff53d180cee8d5b80f291d0c9c3c75d -eo pid,comm
sh: /bin/bash: not found
[Pipeline] }
$ docker stop --time=1 9d50ea59f9db9cc74075029184bf24c1bff53d180cee8d5b80f291d0c9c3c75d
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
The Alpine docker image does not contain bash, only sh.
According to https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#sh-shell-script and interpreter selector may be used, but gives no context as to where to place that selector, just shows a shebang. This leaves to believe that my pipeline example is correct.
The CloudBees support page https://support.cloudbees.com/hc/en-us/articles/215171038-How-do-I-run-a-different-Shell-interpreter-in-a-Pipeline-Script- gives an example, of setting the shebang, but it does so in the node block, which is unrelated to a pipeline. So again the example isn't clear.
How can one change the Shell used in a job, other than changing the Jenkins system wide default shell?