Good idea! I wasn’t sure of the right location to document this, but that link 
looks like a good start. Looking through the related links I think the Writing 
Pipeline Steps 
<https://github.com/jenkinsci/workflow-step-api-plugin/blob/master/README.md> 
or Core Steps 
<https://github.com/jenkinsci/workflow-basic-steps-plugin/blob/master/CORE-STEPS.md#interacting-with-build-status>
 documentation could also use some related updates. I’ll add a task to my TODO 
list to update them.

> On May 15, 2019, at 16:24, Mark Waite <[email protected]> wrote:
> 
> Would you be willing to add this information to the "Writing Pipeline 
> Compatible Plugins 
> <https://jenkins.io/doc/developer/plugin-development/pipeline-integration/>" 
> page on jenkins.io <http://jenkins.io/>?  It seems like a very useful 
> addition to the documentation on that page.
> 
> On Wed, May 15, 2019 at 12:01 PM Devin Nusbaum <[email protected] 
> <mailto:[email protected]>> wrote:
> Pipeline: API 2.34 added a new API called WarningAction 
> <https://github.com/jenkinsci/workflow-api-plugin/blob/c84dbab8cd35c90f70d84390dc711901fa73b7ad/src/main/java/org/jenkinsci/plugins/workflow/actions/WarningAction.java>
>  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 <https://issues.jenkins-ci.org/browse/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:
> 
>   getContext().get(Run.class).setResult(...);
> 
> Keep setting the build result the same way and add code to add a 
> WarningAction to the current FlowNode like this:
> 
>   getContext().get(Run.class).setResult(...);
>   getContext().get(FlowNode.class).addOrReplaceAction(new 
> WarningAction(...).withMessage(...));
> 
> 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 <https://github.com/jenkinsci/junit-plugin/pull/118> 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 
> <https://github.com/jenkinsci/warnings-ng-plugin/pull/58> to Warnings Next 
> Generation Plugin that shows what this kind of change might look like.
> 
> See UnstableStep.java 
> <https://github.com/jenkinsci/workflow-basic-steps-plugin/blob/06075283ed70063937a7175da4852f9ddb087130/src/main/java/org/jenkinsci/plugins/workflow/steps/UnstableStep.java>
>  for an example of a new step that uses the new API.
> 
> Thanks, and let me know if you have any questions!
> 
> Devin
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-dev/4cd76eee-f788-40b2-98a1-51c1172113ec%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-dev/4cd76eee-f788-40b2-98a1-51c1172113ec%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> Thanks!
> Mark Waite
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-dev/CAO49JtEy77cQXeXXCiqVTO_zcbszp3iS40zLMDEMq%2BmtFCFZcg%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-dev/CAO49JtEy77cQXeXXCiqVTO_zcbszp3iS40zLMDEMq%2BmtFCFZcg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/A4E32948-E9C7-4004-A725-41F9B9127393%40cloudbees.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to