Skip to content

Commit

Permalink
Cap runCount in unused JobApi.doDescribe (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick authored Aug 13, 2024
1 parent 634cc71 commit 6038968
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,17 @@ public static JobExt create(WorkflowJob job) {
}

private static int countRuns(WorkflowJob job) {
int maxRunsPerJob = Integer.getInteger(MAX_RUNS_PER_JOB_PROPERTY_NAME, MAX_RUNS_PER_JOB_DEFAULT);

int count = 0;

// RunList.size() is deprecated, so iterating to count them.
// RunList.size() is deprecated *for a good reason*, so iterating to count them.
RunList<WorkflowRun> runs = job.getBuilds();
for (WorkflowRun run : runs) {
count++;
if (count >= maxRunsPerJob) {
break;
}
}

return count;
Expand Down

0 comments on commit 6038968

Please sign in to comment.