我试图在jenkins管道中仅获取当前阶段的控制台输出。我的最终目标是存储此输出,直到构建发布步骤为止,然后通过不和谐通知发出该输出。
stage("Build Javadoc") {
steps {
script {
try {
sh script: "cd ${params.PLUGIN} && /opt/gradle/bin/gradle atherysdoc"
} catch (Exception e) {
exception = e;
failureReason = // Get current stage console output?
throw e;
}
}
}
}
failure {
discordSend webhookURL: "https://discordapp.com/api/webhooks/blahblah",
title: "Build Failure: ${fullPluginName}",
successful: false,
result: 'FAILURE',
link: env.BUILD_URL,
description: "${exception}\n```${failureReason}```"
}
我想要这样做的原因是因为仅发出失败的shell命令异常是因为结果为hudson.AbortException: script returned exit code 1
,这不是很有帮助