Hi Folks,
I have Job-1 and Job-2. 

In Job-2 I am trying to get the latest Promoted Build marked Build# for a 
Job-1. So i am trying this with Grrovy script. Can any one help me to 
achieve this.

I have below script which gives me all the build# for a job. But i want 
only those build which are marked as Promoted.

import hudson.model.*

BUILD_JOB_NAME = "sandbox/Job-1"

def getJobs() {
return Jenkins.instance.getAllItems(AbstractProject.class)
}

def getBuildJob() {
    def buildJob = null
    def jobs = getJobs()
    (jobs).each { job ->
       if (job.fullName == BUILD_JOB_NAME) {
            buildJob = job
        }
    }
    return buildJob
}

def getAllBuildNumbers(Job job) {
    def buildNumbers = []
    (job.getBuilds()).each { build ->
        buildNumbers.add(build.number)
    }
    return buildNumbers
}

def buildJob = getBuildJob()

return getAllBuildNumbers(buildJob) 

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b6752910-915a-40ce-8cf1-1e3dd742a6db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to