[英]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. 插件文档暗示这应该可行。
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.