jenkins - Jenkins Job DSL 在 postBuildScripts shell 中获取当前构建结果
问题描述
我需要在我的 Jenkins DSL 脚本中的 postBuildScripts shell 调用中获取当前构建执行的结果。就像${currentBuild.currentResult}
在具有值的 Jenkins 管道中一样:SUCCESS、UNSTABLE 或 FAILURE
我已经搜索了 DSL 文档,但没有找到任何解决方案。
我的代码是这样的:
postBuildScripts {
steps {
shell("""echo \$CURRENT_BUILD_STATUS""")
}
}
那么如何以$CURRENT_BUILD_STATUS
最简单的方式得到这个呢?
解决方案
不幸的是,PostBuildScript 插件的文档缺少一些有趣的部分......
job('example') {
publishers {
postBuildScripts {
steps {
shell('echo $BUILD_RESULT')
}
}
}
}
推荐阅读
- javascript - 为首屏 DOM 元素初始化 JavaScript 的最佳实践
- android - 我想在 kivy 中使用 Android 默认的后退按钮
- svg - 以 xamarin 形式渲染 svg 导致黑色方块
- ios - hidesBottomBarWhenPushed 推送时奇怪的动画行为
- mongodb - MongoDB + Mongo-Express docker-compose 导致 MongoError: Authentication failed
- java - 在 Azure 中部署时 Java SpringBoot 构建失败 - 无法执行目标 com.microsoft.azure:azure-webapp-maven-plugin:1.1.0:deploy
- c# - 我可以得到其他语言的“YYYY-MM-DD”字符串吗?
- android - 禁用时无法正确设置 TextInputLayout 和 TextInputEditText 样式
- c# - 在没有 MQ 客户端的情况下使用 XMS .Net 连接到 MQ
- r - 如何根据 dplyr 中每组的行数将前“n”个元素添加到数据框中