jenkins pipeline中获取shell命令的输出
//获取标准输出//第一种result = sh returnStdout: true ,script: "<shell command>"result = result.trim()//第二种result = sh(script: "<shell command>", returnStdout: true).trim()//第三种sh "<shell ...
·
//获取标准输出
//第一种
result = sh returnStdout: true ,script: "<shell command>"
result = result.trim()
//第二种
result = sh(script: "<shell command>", returnStdout: true).trim()
//第三种
sh "<shell command> > commandResult"
result = readFile('commandResult').trim()
//获取执行状态
//第一种
result = sh returnStatus: true ,script: "<shell command>"
result = result.trim()
//第二种
result = sh(script: "<shell command>", returnStatus: true).trim()
//第三种
sh '<shell command>; echo $? > status'
def r = readFile('status').trim()
//无需返回值,仅执行shell命令
//最简单的方式
sh '<shell command>'
参考 :
jenkins pipeline中获取shell命令的标准输出或者状态
how-to-execute-a-command-in-a-jenkins-2-0-pipeline-job-and-then-return-the-stdou
how-to-do-i-get-the-output-of-a-shell-command-executed-using-into-a-variable-fro
更多推荐
已为社区贡献2条内容
所有评论(0)