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
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=
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.