Kat*_*tie 5 groovy jenkins jenkins-plugins jenkins-groovy jenkins-pipeline
使用Jenkins Pipeline的sshPublisher插件(“通过ssh发布”),是否可以获取退出代码和运行命令的输出execCommand
(在转移工件之后)?
我正在使用插件,如下所示:
script {
echo "Sending artifacts to machine at " + remoteDirectory
// Use of the ssh publisher plugin over SSH
sshPublisher(
failOnError: false,
publishers: [
sshPublisherDesc(
configName: "my-drive",
transfers: [
sshTransfer(
sourceFiles: mySourceFilesList,
remoteDirectory: remoteDirectory,
flatten: true,
execCommand: commandToExec,
execTimeout: 1800000
)
],
sshRetry: [
retries: 0
]
)
]
)
// How can I get the output of execCommand?
// If the exit code was 1, I want to perform some special steps
// I'd also like to include the output of the command in these steps
}
Run Code Online (Sandbox Code Playgroud)
此处的Wiki页面说(这是古老的,但始于2011年):
命令执行中的STDOUT和STDERR记录在Jenkins控制台中。
这是一个“不”(不能确定,但我尽了一切努力)。
现在我对这个脚本很满意
ssh user@nas01 su -c "/path/to/command1 arg1 arg2"
Run Code Online (Sandbox Code Playgroud)