Jenkins:如果最后一步成功,即使上一步不稳定,也要将Mark构建为成功

时间:2017-01-19 11:52:22

标签: jenkins jenkins-pipeline devops jenkins-workflow

我在詹金斯这样的流程:

Wrapper Job1

  • 触发Job2
  • (有条件地)如果作业2不稳定,则触发Job3

下面你可以看到JOB1(包装器)配置图片:

JOB2触发器配置:

JOB2 trigger configuration

JOB3条件触发器配置

JOB3 conditional trigger configuration

现在,给你一点上下文:

我正在运行使用硒和黄瓜的测试,这些测试可能会随机失败,如果失败,则job2被标记为不稳定(如果不是包装器刚刚完成成功状态),万一job2失败将被触发job3,这是一个" RERUN FAILED TESTS"任务,然后显然在最后这个将成功完成的情况下我希望包装器被标记为SUCCESS。

这应该非常简单,但它不起作用,在包装器(JOB1)jenkins作业日志之下:

第一步(JOB2)不稳定,因为某些测试失败:

Waiting for the completion of REM_Parallel_Tag_Sub_Runner
REM_Parallel_Tag_Sub_Runner #9 completed. Result was UNSTABLE
Build step 'Trigger/call builds on other projects' changed build result    
to **UNSTABLE**

如果JOB2不稳定,那么工作人员就会陷入困境3

[Current build status] check if current [UNSTABLE] is worse or equals then
[UNSTABLE] and better or equals then [UNSTABLE]
Run condition [Current build status] enabling perform for step [BuilderChain]
Waiting for the completion of REM_Parallel_Sub_ReRuns

工作3已经成功,这就是说现在失败的测试已经成功,我希望这一步将JOB1从不稳定变为成功,它应该是正常的行为

 REM_Parallel_Sub_ReRuns #6 completed. Result was SUCCESS
 [CucumberReportPublisher] Compiling Cucumber Html Reports ...
 [CucumberReportPublisher] Copying all json files from: /PATH/workspace  /TiaCukes to reports directory: /PATH/cucumber-html-reports
 [CucumberReportPublisher] there were no json results found in: /u01/app/build/jenkins/jobs/REM_Parallel_Tag_Runner_Orchestrator/builds/9/cucumber-html-reports
 Started calculate disk usage of build
 Finished Calculation of disk usage of build in 0 seconds
 Started calculate disk usage of workspace
 Finished Calculation of disk usage of workspace in 0 seconds
 No emails were triggered.
 Warning: you have no plugins providing access control for builds, so    falling back to legacy behavior of permitting any downstream builds to be triggered

 Finished: UNSTABLE

因为你可以看到建筑状态没有被更新,即使最后触发的步骤成功,建筑状态仍然不稳定

我该如何解决?不应该这么难实现目标!

非常感谢!

1 个答案:

答案 0 :(得分:0)

使用参数化触发插件设置的变量解决:

https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin

下面的图片:

JOB2触发器配置: JOB2 trigger configuration

JOB3条件触发器配置: enter image description here

随时询问详情