Groovy script to get the success builds which are promoted of particular jenkins job.

17 views
Skip to first unread message

raja saggam

unread,
Sep 10, 2017, 3:47:31 PM9/10/17
to Jenkins Developers
Below is script i'm using to get the success builds and filtering then to get only matching label. 

please help me out how to list of success builds promoted? 
any help could be appreciable. thanks in advance.

def jobname="test" 
def list=[]
hudson.model.AbstractProject<?, ?> otherJob = jenkins.model.Jenkins.getInstance().getItemByFullName(jobname, hudson.model.AbstractProject.class)
hudson.util.RunList<?> builds = otherJob.getBuilds().overThresholdOnly(hudson.model.Result.SUCCESS.promoted-builds.SUCCESS)
builds.limit(20).each{run -> 
        switch( run.displayName ) {
        case ~/^5.*.*.*/  :
            list.add(run.displayName)
            break
         default :
            break            
    }
 }

 list
Reply all
Reply to author
Forward
0 new messages