jenkins构建联动功能(三)

韵味老鸟 2024-07-19 15:07:02

jenkins构建联动功能 (三)

调试输出脚本控制

output.tokenize('\n') 的命令作用,就是针对换行输出的结果,转换成三个元素的列表组

#执行案例2

import java.util.concurrent.TimeUnitdef remoteServer = '192.168.10.17'def remoteUser = 'root'def sshCommand = """ ssh root@192.168.10.17 ' helm list '"""def processBuilder = new ProcessBuilder('bash', '-c', sshCommand)processBuilder.redirectErrorStream(true) // 将错误输出与标准输出合并def process = processBuilder.start()process.waitFor(5, TimeUnit.SECONDS) // 等待进程退出,设置一个适当的超时时间def result = ''if (process.exitValue() == 0) { result = process.text.trim()}println "Command output: " + result

脚本输出可调试

0 阅读:5