简体   繁体   English

如何使用Groovy Postbuild强制工作获得成功?

[英]How can I use Groovy Postbuild to force a job to success?

I am trying to force a unit test job to success if the main build returned a failed exit code. 如果主版本返回失败的退出代码,我试图强制单元测试作业成功。 Here is how I configured it and it is not working (see screenshot). 这是我的配置方式,它不起作用(请参见屏幕截图)。 Does anyone know any reason why this shouldn't work? 有谁知道为什么这不起作用? In this example I just want to show that a failing job can be changed to a passing job by a groovy postbuild step. 在此示例中,我仅想显示可以通过繁琐的后期构建步骤将失败的工作更改为通过的工作。 The plugin doc implies that this should work. 插件文档暗示这应该可行。

  1. The main build runs a batch script with "EXIT 1" to fail the build. 主版本运行带有“退出1”的批处理脚本以使构建失败。
  2. A Groovy Postbuild step runs manager.buildSuccess() in an attempt to force the build to success (but it fails to do so with no error). Groovy Postbuild步骤运行manager.buildSuccess()试图强制构建成功(但这样做没有错误)。

我的截图

I found a discussion about that problem on jenkins-JIRA . 我在jenkins-JIRA上找到了关于该问题的讨论。

As a workaround it is proposed to use reflection to make the build successful: 作为一种解决方法,建议使用反射使构建成功:

manager.build.@result = hudson.model.Result.SUCCESS

This workaround doesn't work for me, but perhaps it can help you 这种解决方法对我不起作用,但也许可以为您提供帮助

Install Groovy Post Build Plug in. Then add the below Groovy Script. 安装Groovy Post Build插件。然后添加以下Groovy脚本。

manager.build.@result = hudson.model.Result.SUCCESS

Uncheck the Use Groovy Sandbox. 取消选中“使用Groovy沙箱”。 This worked for me. 这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Groovy Postbuild插件在项目/作业主页上书写? - How can use Groovy Postbuild Plugin to write on the project/job main page? 如何使用构建后 groovy 构建下游作业 - How to build a downstream job with postbuild groovy 如何在 Jenkins 中永久使用 Groovy PostBuild 更新全局环境变量并在其他后续构建中使用它? - How can I update a global Environment Variable using Groovy PostBuild in Jenkins permanently and use it in other subsequent builds? 如何从groovy Postbuild插件访问Jenkins构建工件? - How can I access Jenkins build artifacts from the groovy Postbuild plugin? 如何标记jenkins构建不稳定与groovy postbuild - How to mark the jenkins build unstable with groovy postbuild Groovy Postbuild如何检查先前的post-build操作的日志消息 - How can Groovy Postbuild check the log message of a previous post-build action Jenkins Groovy Postbuild使用静态文件而不是脚本 - Jenkins Groovy Postbuild use static file instead of script 我可以使用Jenkins CLI或一些常规脚本来创建新作业吗 - Can I use Jenkins CLI or some groovy scripts to create a new job 我如何使用詹金斯工作来循环另一个詹金斯工作 - how can I use a jenkins job to loop another jenkins job 我该如何创建一个使用作业DSL运行Groovy代码的作业? - how do I create a job that runs groovy code with the job dsl?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM