mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
[FIXED HUDSON-6544] calculate estimated remaining time for incremental Maven builds based on the modules which are actually being build
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@36164 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
6f007c88d1
commit
b9b433b1f2
6 files changed
+137
-5
No files matched your search
@@ -211,6 +211,64 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the estimated duration for this builds.
|
||||
* Takes only the modules into account which are actually being build in
|
||||
* case of incremental builds.
|
||||
*/
|
||||
@Override
|
||||
public long getEstimatedDuration() {
|
||||
|
||||
if (!project.isIncrementalBuild()) {
|
||||
return super.getEstimatedDuration();
|
||||
}
|
||||
|
||||
long result = 0;
|
||||
|
||||
Map<MavenModule, List<MavenBuild>> moduleBuilds = getModuleBuilds();
|
||||
for (List<MavenBuild> builds : moduleBuilds.values()) {
|
||||
if (!builds.isEmpty()) {
|
||||
MavenBuild build = builds.get(0);
|
||||
if (build.getResult() != Result.NOT_BUILT) {
|
||||
if (build.getEstimatedDuration() != -1) {
|
||||
result += build.getEstimatedDuration();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result += estimateModuleSetBuildDurationOverhead(3);
|
||||
|
||||
return result != 0 ? result : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimates the duration overhead the {@link MavenModuleSetBuild} itself adds
|
||||
* to the sum of duration of the module builds.
|
||||
*/
|
||||
private long estimateModuleSetBuildDurationOverhead(int numberOfBuilds) {
|
||||
List<MavenModuleSetBuild> moduleSetBuilds = getPreviousBuildsOverThreshold(numberOfBuilds, Result.UNSTABLE);
|
||||
|
||||
if (moduleSetBuilds.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long overhead = 0;
|
||||
for(MavenModuleSetBuild moduleSetBuild : moduleSetBuilds) {
|
||||
long sumOfModuleBuilds = 0;
|
||||
for (List<MavenBuild> builds : moduleSetBuild.getModuleBuilds().values()) {
|
||||
if (!builds.isEmpty()) {
|
||||
MavenBuild moduleBuild = builds.get(0);
|
||||
sumOfModuleBuilds += moduleBuild.getDuration();
|
||||
}
|
||||
}
|
||||
|
||||
overhead += Math.max(0, moduleSetBuild.getDuration() - sumOfModuleBuilds);
|
||||
}
|
||||
|
||||
return Math.round((double)overhead / moduleSetBuilds.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void delete() throws IOException {
|
||||
|
||||
Reference in new issue
Block a user