Jenkins Job DSL 在 postBuildScripts shell 中获取当前构建结果



我需要在我的 Jenkins DSL 脚本中的 postBuildScripts shell 调用中获取当前构建执行的结果。就像 Jenkins 管道中的${currentBuild.currentResult}一样,其值为:成功、不稳定或失败

我已经搜索了DSL文档,但没有找到任何解决方案。

我的代码是这样的:

postBuildScripts {
steps {
shell("""echo $CURRENT_BUILD_STATUS""")
}
}

那么如何以最简单的方式获得这个$CURRENT_BUILD_STATUS呢?

不幸的是,PostBuildScript 插件的文档缺少一些有趣的部分......

job('example') {
publishers {
postBuildScripts {
steps {
shell('echo $BUILD_RESULT')
}
}
}
}

最新更新