dear experts,
I have a Jenkins pipeline job in which I configure my environment with a bash script named setup.sh which looks like:
#!/bin/bash
export ARCH=$1
echo "architecture = " ${ARCH}
In the Jenkins pipeline script, Icall the setup.sh script with:
def lib_arch='linux-ubuntu-14.04-x86_64-gcc4.8.4'
sh ". /opt/setup.sh ${lib_arch}"
unfortunately it seems that NO variable is passed to the setup.sh script, and the echo ${ARCH} return an empty string!
In addition, I tried to instead do:
sh "source /opt/setup.sh ${lib_arch}"
but this fails as well with the "source not found" message. I also tried changing the first line of my script to
#!/bin/sh
but it does not help.
So how can I pass a parameter to my bash script in a Jenkins pipeline script?
thanks for your help.
def lib_arch='linux-ubuntu-14.04-x86_64-gcc4.8.4' echo lib_arch
echo ". /opt/setup.sh ${lib_arch}" echo ". /opt/setup.sh $lib_arch"
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/537fa03f-d87e-4df6-bf23-68e5d9a82db5%40googlegroups.com.
#!/bin/bash
export ARCH=$1
echo "architecture = " $ARCH
Braces around the 'ARCH' variable is not required.
Although it's too late to answer, it might help someone else.
There is an extra space between your (.) and your opt/setup.sh.
If the variabel come from Jenkins pipeline script, you need double quote (“) to get evaluate, single quote (‘) won’t. You should also pass the value as a string and escape it for your argument something like this:
def lib_arch='linux-ubuntu-14.04-x86_64-gcc4.8.4'
sh(script: "./opt/setup.sh \”${lib_arch}\”")
;
That should normally work just fine.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/2f3a7f54-d7bf-42ac-bc3e-fc967bc76779%40googlegroups.com.