Wie zum ausführen eines shell-scripts auf remote-Maschine Via ssh mit jenkins-job

Möchte ich laufen Sie ein shell-Skript auf dem remote-Rechner nach der Anmeldung über ssh.
Hier ist mein code.

#!/bin/bash 
USERNAME=user
HOSTS="172.20.16.120"

für HOSTNAME in ${HOSTS} ;
sshpass -p Passwort ssh -t -t ${USERNAME}@${HOSTNAME}

echo [QACOHORT-INFO] Space Before clean up

df -h

callworkspace()

{
if [ "$?" = "0" ];

then

for i in `ls`; do 

if [ "$1" = "workspace" ] &&  echo "$i" | grep -q "$VERSION_WS" && [ "$VERSION_WS" != "" ];

then

echo [QACOHORT-INFO] Removing files-in:
pwd

rm -rf $i

echo [QACOHORT-INFO] Removed: $i

fi

if echo "$i" | grep -q "wasabi$VERSION_HUDSON"  && [ "$VERSION_HUDSON" != "" ];

then
echo [QACOHORT-INFO] Removing files-in $i

rm -rf $i/*

elif echo "$i" | grep -q "wasabiSDK$VERSION_HUDSON"  && [ "$VERSION_HUDSON" != "" ];

then

echo [QACOHORT-INFO] Removing files-in $i

#rm -rf $i/*

fi

done

fi
}

unamestr=`uname`

if [ "$unamestr" = "Linux" ];

then

cd /home/jenkin/workspace/Hudson/

callworkspace

cd /home/jenkin/workspace/Hudson/workspace

callworkspace workspace

echo [QACOHORT-INFO] Removing temp files

rm -rf /tmp/tmp* 

rm -rf ~/.local/share/Trash/*

else [ "$unamestr" = "Darwin" ];

cd /Users/ITRU/ws/Hudson/

callworkspace

cd /Users/ITRU/ws/Hudson/workspace

callworkspace workspace

echo [QACOHORT-INFO] Removing temp files

rm -rf /tmp/tmp* 

rm -rf ~/.Trash/*

fi

unamestr=`uname -o`

if [ "$unamestr" = "Cygwin" ];

then

cd D:/work/Hudson

callworkspace

cd D:/work/Hudson/workspace

callworkspace workspace

fi


echo [QACOHORT-INFO] Space after clean up
df -h 
done
exit 0

Nach der Anmeldung über ssh, ich muss die folgenden Zeilen nach ssh als shell-Skript nur. Ich will nicht zu halten dieser Linien .sh Datei und ausführen. Ich muss es in jenkins. Kann mir jemand helfen?

Bitte korrigieren Sie die code-Einrückung. Verwenden {} während der Bearbeitung

InformationsquelleAutor Pavan Kumar | 2015-04-24

Schreibe einen Kommentar