Pipeline: API 2.34 added a new API called WarningAction
that allows steps to report irregular but non-fatal events that occurred during their execution while allowing Pipeline execution to continue normally. This allows long-standing and highly-voted issues such as JENKINS-39203
to be fixed by modifying Pipeline steps that change the build result directly to also use the new API so that visualizations such as Blue Ocean use the new API (through Pipeline: Graph Analysis 1.10) to display more specific statuses. For any maintainers of plugins setting the build result directly today, here is some information to help you understand how to use the new API if you would like to do so.
First, if you have a step that throws an exception today to indicate failure, that's totally fine, keep doing that! The new API only applies to steps that want to indicate some kind of problem but continue normal Pipeline execution.
For regular Steps, if you have code in a StepExecution that does something like this and want to use the new API:
Keep setting the build result the same way and add code to add a WarningAction to the current FlowNode like this:
The result you pass to the WarningAction constructor will determine how Blue Ocean displays your step and the stage or parallel branch enclosing your step. The message is optional and may be visualized directly in Blue Ocean in some prominent way in the future, but for now it is not shown anywhere.
See this pull request to JUnit plugin for an example of how to integrate a plugin with the new API (in particular the changes to JUnitResultsStepExecution.java). If your plugin currently uses SimpleBuildStep or SimpleBuildWrapper to implement a step that can be used in Freestyle and Pipeline jobs, there is no way to use the new API directly, and you need to create a new Pipeline Step to be able to use the new API. You should be able to call the SimpleBuildStep from your new Step to avoid duplicating logic, but unfortunately you will need to duplicate getters and setters to make data-binding work correctly for the step. Here is an in-progress PR to Warnings Next Generation Plugin that shows what this kind of change might look like.
Thanks, and let me know if you have any questions!