Reputation: 1398
I have the below shell script:
du -sh /bbhome/shared/data/repositories/* |sort -h |tail -20 |
while IFS= read -r line;do
DIR=`echo $line | awk '{print$2}'`
Rep=`cat $DIR/repository-config |grep 'project\|repo' | tr '\n' ' '`
Size=`echo $line | awk '{print $1}' `
echo $Size $Rep
done
How can I run it thought Execute shell in Jenkins? I need also to add ssh command to the env (no need for a password). Note I don't want to connect to the env and run this shell, but directly from Excecue shell box
Upvotes: 0
Views: 265
Reputation: 316
If I'm not wrong your are using a Freestyle job and not a pipeline job. Anyway, I think you have to try the following :
ssh -t XXXXX@YYYYY << 'EOF'
du -sh /bbhome/shared/data/repositories/* |sort -h |tail -20 |
while IFS= read -r line;do\
DIR=
echo $line | awk '{print$2}'\
Rep=
cat $DIR/repository-config |grep 'project\|repo' | tr '\n' ' '\
Size=
echo $line | awk '{print $1}' \
echo $Size $Rep\
done
EOF
I've escaped the code inside your while loop using \, if it's doesn't works you can use ; instead.
If you want help for using a pipeline job, let me know but i might be a bit more complex.
Upvotes: 2