I have a bash shell script executed by Jenkins / Hudson. For some reason when I create a function, the output of that function is not logged back to the console. This is an example of my code:
EDIT!!! - this culprit here is SSH... Is there a way to force its output back to console?
perform_task()
{
ssh [email protected] pwd
}
echo "Starting a task";
perform_task || { echo "The Task Failed"; exit 1; }
The output in the console is:
"Starting a task"
if I move the commands outside of the function, I can see their output.
Help on this would be greatly appreciated!
I partially solved the problem by getting the script to echo the command:
#!/bin/bash -ex
This still hides the output of that command, but at least I have insights about what's being run
I just copied your function, added #!/bin/bash -e to the beginning of and pasted it into the "Execute Shell" of Jenkins.
It worked fine!
Is your bash executable actually located at /bin? What OS are you running the script on?
Building remotely on slave_1
[test] $ /bin/bash -xe /tmp/hudson1206345540964396738.sh
+ echo 'Starting a task'
Starting a task
+ perform_task
+ ssh slave_2 pwd
/home/jenkins
Finished: SUCCESS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With