Jenkins pipeline refuses to use bash

Viewed 33

Kind of related to What shell does Jenkins use?

On our jenkins server Manage Jenkins --> Configure System --> Shell executable is left blank, so by default it should be bash. Even then, I added

#!/usr/bin/env bash

to the top of my script to try to force it again. All I'm trying to do is execute

....
dir('test')
{
    sh """
    pwd
    . ./sourceme.env -t ARM
    ....
}
....

And I get

....
+ [[  ==  ]]
/home/jenkins/workspace/Valgrind/mclinux@tmp/durable-607e8283/script.sh: 26: ./sourceme.env: [[: not found
+ [[ !=  ]]
/home/jenkins/workspace/Valgrind/mclinux@tmp/durable-607e8283/script.sh: 31: ./sourceme.env: [[: not found
+ releaseFile=releases/.xml
+ [[ ! -f releases/.xml ]]
/home/jenkins/workspace/Valgrind/mclinux@tmp/durable-607e8283/script.sh: 59: ./sourceme.env: [[: not found
....

I remember seeing this behavior before on a new development machine when I learned that it used dash by default. Like so

> dash sourceme.env -t ARM -v IXM210 -s 1 -m
 sourceme.env: 26: sourceme.env: [[: not found
 sourceme.env: 31: sourceme.env: [[: not found
 sourceme.env: 59: sourceme.env: [[: not found

I'm also having issues with @tmp directories being created even when I specify a specific directory to use with dir('test'). Which is why I had to prefix sourceme.env with ./ Which I guess is a known issue: https://issues.jenkins.io/browse/JENKINS-52750?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel

The crazy thing is we have other pipelines that also use

sh """ many lines of stuff """

to include source'ing .env files without issue and I can't seem to find any extra configuration and pipeline script items that seem to been specific to resolving any issues they had in the past.

This is my first day dabbling with jenkins, so I'm guessing I missed something.

0 Answers
Related