Last active
          October 3, 2019 23:41 
        
      - 
      
 - 
        
Save carlos-jenkins/4340bfd0c9703b3896df3d8bf344b189 to your computer and use it in GitHub Desktop.  
    Jenkins script to get job queues
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import groovy.json.JsonOutput | |
| result = [] | |
| Jenkins.instance.queue.items.each { | |
| // Only consider BuildableItem | |
| // Other known objects are: | |
| // - BlockedItem, which lacks the runId | |
| if (it instanceof Queue.BuildableItem) { | |
| result.add([ | |
| name: it.task.runId, | |
| id: it.id, | |
| why: it.why, | |
| startTime: it.inQueueSince, | |
| ]) | |
| } | |
| } | |
| print(JsonOutput.toJson(result)) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment