The below is my Jenkins Pipeline stage
stage ('Import') {
steps {
sshagent([sshCredentials]) {
sh '''
#!/bin/bash
sh -x ETL_AUTOMATION/Scripts/export.sh
'''
Build output:-
[[ RMO_TST12 == ]]
ETL_AUTOMATION/Scripts/export.sh: 17: ETL_AUTOMATION/Scripts/export.sh: [[: not found
if
condition in script:-
if [[ "$SOURCE_FOLDER" == "" ]]; then
echo "SOURCE_FOLDER not specified... exiting"
exit 1
fi
I have mentioned #!/bin/bash
in my script also.
Please help me, I am really stuck here.
You are running
sh -x ETL_AUTOMATION/Scripts/export.sh
. This means thatexport.sh
is being run bysh
and notbash
. On Ubuntu,sh
is a simple POSIX shell calleddash
and that doesn't support the[[
construct, which is abash
thing. So just change your script so that it is launched withbash
instead ofsh
. I don't know the Jenkins syntax at all, but I suspect you want one of these:or, if your
export.sh
isn't executable:Or, perhaps simply:
Alternatively, you can change
export.sh
so it doesn't use bash-only features: