我在Jenkinsfile(Groovy)上有这样的东西,我想在变量中记录stdout和退出代码,以便稍后使用这些信息.
sh "ls -l"
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做,特别是因为你似乎无法在里面运行任何类型的groovy代码Jenkinsfile?
这个问题的答案受到@codeGeass对How toexecute a command in a Jenkins 2.0 Pipeline job and then return the stdout 的回答的评论的启发:
我们可以一起使用它们吗?在变量中捕获 returnStdout 并在另一个变量中捕获 returnStatus ?因为重复 sh 脚本两次并不酷