【发布时间】:2019-05-01 16:08:50
【问题描述】:
我有一个 Jenkins 声明式管道,它在构建状态成功时运行良好。
但是,当 UI 测试失败并且构建状态设置为失败时,post 步骤中的所有代码都会被忽略。
我已经检查过是否可能在测试失败的情况下未创建测试报告,但这些报告存在于指定位置。
我不知道为什么 Jenkins 不会在构建失败的情况下始终运行帖子。
我希望帖子总是在失败或成功的情况下运行,谁能向我解释为什么它不运行?
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 */
}
}
}
【问题讨论】:
-
这是
scripted pipeline还是Declarative管道 -
嗨 Gaurang,这是关于声明性管道的。
-
你能在
node('master')之前尝试echo "always",看看你是否在日志中收到这条消息。