Skip to content

Commit 2942646

Browse files
Improve search for the specific job
Co-authored-by: Denys Digtiar <[email protected]>
1 parent 9b89835 commit 2942646

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

fetch-builds-by-date-range-for-specific-job.groovy

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ def jobName = 'changeMe'
99

1010
println "Will return all the builds for job ${jobName} that ran between ${startDate} and ${endDate}"
1111

12-
def builds = Jenkins.instance.getAllItems()
13-
.findAll { it instanceof Job && it.fullName == jobName }
14-
.collect { it.builds.byTimestamp(startDate.toEpochMilli(), endDate.toEpochMilli()) }
15-
.flatten()
12+
def builds = Jenkins.get().getItemByFullName(jobName, hudson.model.Job).builds.byTimestamp(startDate.toEpochMilli(), endDate.toEpochMilli())
1613

1714
return builds

0 commit comments

Comments
 (0)