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)