示例:
stage("Jar Files Check") { steps{ script{ smd5 = sh(script: "ssh $host md5sum $APP_SEND_PATH/datacenter-${projectname}.jar|awk '{print \$1}'", returnStdout: true).trim() sh "echo 'smd5:' $smd5" for ( HOST in HOSTS ){ stage("Md5 to ${HOST}"){ dmd5 = sh(script: "ssh $host ssh ${HOST} md5sum $Deploy_PATH/datacenter-${projectname}.jar|awk '{print \$1}'", returnStdout: true).trim() sh "echo 'dcentermd5:' $dcentermd5" if ( smd5 == dmd5){ sh "echo ${HOST} 传输完成 " }else{ sh "echo ${HOST} Jar File 传输未完成" sleep 10 } } } } } }
标准输出 bianliang = sh returnStdout: true ,script: "<shell command>" bianliang = result.trim() bianliang = sh(script: "<shell command>", returnStdout: true).trim() 获取执行状态 bianliang = sh returnStatus: true ,script: "<shell command>" bianliang = result.trim() bianliang = sh(script: "<shell command>", returnStatus: true).trim() sh '<shell command>; echo $? > status' def bianliang = readFile('status').trim()
标签:trim,bianliang,Pipeline,shell,script,echo,sh,Jenkins,true From: https://www.cnblogs.com/musen/p/17533033.html