System Groovy script to list results of previous pipeline executions

10 views
Skip to first unread message

Gabriel Corrêa de Oliveira

unread,
Sep 21, 2017, 9:55:33 PM9/21/17
to Delivery Pipeline Plugin
Dear All,

I am trying to write a System Groovy script to print a list of all my previous pipeline runs with their respective total time and status. For the status, I need to consider that the whole pipeline failed if any of the jobs involved failed.

So far, I managed to write the following:

import se.diabol.jenkins.pipeline.DeliveryPipelineView
import se.diabol.jenkins.pipeline.domain.Component
import se.diabol.jenkins.pipeline.domain.Pipeline
import se.diabol.jenkins.pipeline.domain.status.StatusType

pipelineView
= Jenkins.activeInstance.getView('essentials-master-pipeline')

pipelineView
.getPipelines().collectMany { comp ->

  comp
.getPipelines().collect { pipeline ->
   
[cn: comp.componentNumber,  timeStamp: pipeline.timestamp, totalBuildTime: pipeline.totalBuildTime,
     buildName
: pipeline.version, triggeredBy: pipeline.triggeredBy.description,
     success
: pipeline.allTasks.values.any { it.status != StatusTyep.SUCCESS } ]
 
}
}

However, this only gives me access to the pipeline runs on the first page.

I've been reading the source code, but I still couldn't understand what would be the best way to gain access to a complete list of all the previous pipeline executions.

Any help would be very welcome.
Reply all
Reply to author
Forward
0 new messages