| << Back to previous view |
[QB-4225] Get durations of last n builds and duration of each step in QuickBuild configuration
|
|
| Status: | Closed |
| Project: | QuickBuild |
| Component/s: | None |
| Affects Version/s: | 14.0.25 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Phong Trinh | Assigned To: | Robin Shen |
| Resolution: | Won't Fix | Votes: | 0 |
| Remaining Estimate: | Unknown | Time Spent: | Unknown |
| Original Estimate: | Unknown | ||
| Description |
|
I am trying get durations of last10 builds of a QuickBuild configuration and the duration of each step in the configuration in a groovy script. Any suggestion is appreciated.
Thank you in advance, ptring |
| Comments |
| Comment by Robin Shen [ 09/Dec/25 11:29 PM ] |
|
Please use below groovy script. It get latest 10 builds of root configuration, and prints the average build and step duration:
groovy: import com.pmease.quickbuild.SearchCriteria; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; def statsConf = system.configurationManager.get("root"); def totalBuildDuration = 0; def totalBuildCount = 0; def totalStepDurationMap = [:]; def totalStepCountMap = [:]; def criterions = [Restrictions.eq("configuration", statsConf)] as Criterion[]; for (eachBuild in system.buildManager.search(new SearchCriteria(criterions, new Order[]{Order.desc("id")}), 0, 10)) { if (eachBuild.duration != null) { totalBuildDuration += eachBuild.duration; totalBuildCount++; } for (eachEntry in eachBuild.stepRuntimes.entrySet()) { if (eachEntry.value.duration != null) { totalStepDurationMap[eachEntry.key] = totalStepDurationMap.get(eachEntry.key, 0) + eachEntry.value.duration; totalStepCountMap[eachEntry.key] = totalStepCountMap.get(eachEntry.key, 0) + 1; } } } logger.info("average build duration: " + (totalBuildDuration / totalBuildCount)); for (entry in totalStepDurationMap.entrySet()) { logger.info("average duration for step " + entry.key + ": " + entry.value / totalStepCountMap[entry.key]); } |
| Comment by Phong Trinh [ 10/Dec/25 03:16 AM ] |
| Thank you very much, Robin! |