Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rest API in Jenkins to get the Pipeline (stages) information

I'm exploring the options to get the pipeline (stages) information in Jenkins through Rest API. We had a pipeline plug-in installed on Jenkins.

Any help on same is highly appreciated.

like image 216
Vineet Kumar Avatar asked May 29 '18 23:05

Vineet Kumar


People also ask

How do I get stage view in Jenkins?

When you run some builds, the stage view will appear with Checkout, Build, and Test columns, and one row per build. When hovering over a stage cell you can click the Logs button to see log messages printed in that stage: after the preceding stage step and before the next one.

How do I access REST API Jenkins?

The simplest way to access Jenkins REST API is to gather the User Token which is available by selecting your User and clicking on Configure. Now you will use the token as parameter for your authentication.

How do I get a list of pipelines in Jenkins?

On the Manage Jenkins page for your installation, navigate to Manage Plugins. Find Pipeline Plugin from among the plugins listed on the Available tab. (You can do this by scrolling through the plugin list or by using “Pipeline” as a term to filter results) Select the checkbox for Pipeline Plugin.


Video Answer


1 Answers

You can use this endpoint to get the pipeline runs:

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

Each run blob should contain the corresponding stages, so you can extract the stages of the latest run.

like image 65
Vasiliki Siakka Avatar answered Sep 21 '22 16:09

Vasiliki Siakka