
|
If you were logged in you would be able to see more operations.
|
|
|
QuickBuild
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
|
|
|
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
|
|
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 |
Show » |
|
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]);
}