I have a script that uses sh
shell. I get an error in the line that uses the source
command. It seems source
is not included in my
This problem happens because jenkins Execute Shell runs the script via its /bin/sh
Consequently, /bin/sh does not know "source"
You just need to add the below line at the top of your Execute Shell in jenkins
#!/bin/bash
$ls -l `which sh`
/bin/sh -> dash
$sudo dpkg-reconfigure dash #Select "no" when you're asked
[...]
$ls -l `which sh`
/bin/sh -> bash
Then it will be OK
I found in a gnu Makefile on Ubuntu, (where /bin/sh -> bash)
I needed to use the . command, as well as specify the target script with a ./ prefix (see example below)
source did not work in this instance, not sure why since it should be calling /bin/bash..
My SHELL environment variable is also set to /bin/bash
test:
$(shell . ./my_script)
Note this sample does not include the tab character; had to format for stack exchange.
On Ubuntu, instead of using sh scriptname.sh to run the file, I've used . scriptname.sh and it worked!
The first line of my file contains:
#!/bin/bash
use this command to run the script
.name_of_script.sh
In Bourne shell(sh), use the . command to source a file
. filename
This may help you, I was getting this error because I was trying to reload my .profile
with the command . .profile
and it had a syntax error