History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: QB-4225
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Robin Shen
Reporter: Phong Trinh
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
QuickBuild

Get durations of last n builds and duration of each step in QuickBuild configuration

Created: 09/Dec/25 03:29 AM   Updated: 10/Dec/25 03:16 AM
Component/s: None
Affects Version/s: 14.0.25
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown


 Description  « Hide
 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

 All   Comments   Work Log   Change History      Sort Order:
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]);
}

Phong Trinh [10/Dec/25 03:16 AM]
Thank you very much, Robin!