詹金斯管道帖子总是步骤在失败的构建时不执行



我有一个Jenkins声明性管道,当构建状态成功时,它运行得很好。

但是,当UI测试失败,并且生成状态设置为失败时,post-always步骤中的所有代码都将被忽略。

我已经检查了在测试失败的情况下是否没有创建测试报告,但这些报告存在于指定的位置。

我不知道为什么詹金斯不会在构建失败的情况下运行帖子。

我希望帖子总是在失败或成功的情况下运行,有人能向我解释为什么没有吗?

post {
always {
node('master') {
dir('/appl/jenkins/test/workspace/pipeline/test-reports') {
unstash 'test-report'
// This plugin script replaces the hard coded D: drive references with the path of the Jenkins job
// in order to make screenshot links function OK in the Jenkins copy of the HTML report.
//TODO add build number to report to identify test run.
echo 'Run completed before script block'
script {
contentReplace(
configs: [
fileContentReplaceConfig(
configs: [
fileContentReplaceItemConfig(
search: 'original_path',
replace: 'replaced_path',
matchCount: 0)
],
fileEncoding: 'UTF-8',
filePath: '/appl/jenkins/test/workspace/pipeline/test-reports/report.html')
])
}
echo 'Run completed after script block'
// Below we use the Publish HTML plugin to publish the report.html resulting from the Extend Reports plugin.
publishHTML target: [
allowMissing         : false,
alwaysLinkToLastBuild: false,
keepAll              : true,
reportDir            : '/appl/jenkins/test/workspace/pipeline/test-reports',
reportFiles          : 'report.html, *.png',
reportName           : 'Extent Report deluxe (screenshots!)'
]
echo 'Run completed after publish block'
//deleteDir() /* clean up Master workspace */
}
}
}

我已经将post-always步骤直接添加到我的管道中的测试步骤的末尾,而不是管道的绝对末尾,现在它可以工作了。

我认为这是Jenkins的管道机制中的一个错误,否则我希望后一步永远不会运行,而只是在一个成功的场景中。

确保在构建"propagation"时未设置为true,如果设置为true则将其更改为propagation:false

最新更新