pycontribs / jenkinsapi

A Python API for accessing resources and configuring Hudson & Jenkins continuous-integration servers
http://pypi.python.org/pypi/jenkinsapi
MIT License
857 stars 483 forks source link

How to get stage result or stage console output for a declarative pipeline? #813

Open solarjoe opened 3 years ago

solarjoe commented 3 years ago
ISSUE TYPE
Jenkinsapi VERSION

0.3.11

Jenkins VERSION

2.190.1

SUMMARY

I would like to pass feedback from our (declarative) pipeline to the publisher of a pull request, especially if and maybe where the pipeline failed. Is there a way to access the stage result or stage console output.

You could parse this out of the console output, but maybe there is a better way.

solarjoe commented 3 years ago

I think I found a solution.

The plugin Pipeline Stage View Plugin https://plugins.jenkins.io/pipeline-rest-api/ seems to be installed out-of-the-box for current Jenkins installations.

And it provides endpoints that are not used in jenkinsapi so far:

https://github.com/jenkinsci/pipeline-stage-view-plugin/tree/master/rest-api#get-jobjob-namewfapiruns

https://stackoverflow.com/a/38876067/7919597