I'm trying to pass a script on a remotehost without getting the command outputs on the jenkins console. an example script:
ssh -o StrictHostKeyChecking=no -t -t update@dispotest bash -s 'hello' <<'END'
printf '%s world!\n' "$1"
exit
END
produces following output:
+ sh start_stop_jboss_remote.sh
printf '%s world!\n' "$1"
exit
[update@dispotest ~]$ printf '%s world!\n' "$1"
hello world!
[update@dispotest ~]$
[update@dispotest ~]$ exit
exit
Connection to dispotest closed.
Finished: SUCCESS
My main issue is that the whole part between the two endssh will be postet in the console output of jenkins even twice. The first time i guess is for starting the ssh session and the second time is inside the ssh session. This makes finding the right place to look quiet hard. So i was hoping someone has a idea how to hide the script itself from the console. But i don't wan't to mute it completely. I'm still interested in the output of the commands running in the ssh session.
I have experimented with > /dev/null alot. but often also the output of the echo or the command executed in the shell where gone which i d like to preserve.
some examples i tried
ssh -o StrictHostKeyChecking=no -t -t update@dispotest bash -s 'hello' <<'END'
{
printf '%s world!\n' "$1"
exit
} 2> /dev/null
END
outputs at least the commands bundled
+ sh start_stop_jboss_remote.sh
{
printf '%s world!\n' "$1"
exit
} 2> /dev/null
[update@dispotest ~]$ {
>
> printf '%s world!\n' "$1"
> exit
>
> } 2> /dev/null
hello world!
Connection to dispotest closed.
Finished: SUCCESS
example 3
ssh -o StrictHostKeyChecking=no -t -t update@dispotest bash -s 'hello' 2> /dev/null <<'END'
printf '%s world!\n' "$1"
exit
END
outputs
+ sh start_stop_jboss_remote.sh
printf '%s world!\n' "$1"
exit
[update@dispotest ~]$ printf '%s world!\n' "$1"
hello world!
[update@dispotest ~]$ exit
exit
Finished: SUCCESS
example 4
ssh -o StrictHostKeyChecking=no -t -t update@dispotest bash -s 'hello' 2> /dev/null <<'END'
{
printf '%s world!\n' "$1"
exit
} 2> /dev/null
END
outputs
+ sh start_stop_jboss_remote.sh
{
printf '%s world!\n' "$1"
exit
} 2> /dev/null
[update@dispotest ~]$ {
> printf '%s world!\n' "$1"
> exit
> } 2> /dev/null
hello world!
Finished: SUCCESS