阅读了 Jenkins tutorial 解释 Pipeline 插件后,似乎该插件应该能够实现构建后步骤。然而,文档在具体说明方面相当有限。
例如,我想知道如何实现:
例如,我想知道如何实现:
- 只在构建成功时运行
- 仅在构建成功或不稳定时运行
- 无论构建结果如何都要运行
Run only if build succeeds
stage 'build' ... build ... tests stage 'post-build' ...
(Or add
-Dmaven.test.failure.ignore=false
to theMAVEN_OPTS
)Run only if build succeeds or is unstable
stage 'build' ... build try { ... tests } catch { ... } stage 'post-build' ...
(Or add
-Dmaven.test.failure.ignore=true
to theMAVEN_OPTS
)Run regardless of build result - could it be done using
try / catch / finally
?try { stage 'build' ... } catch { ... } finally { stage 'post-build' ... }
currentBuild.result = 'UNSTABLE'
?