Commit
…which were not already loaded. (cherry picked from commit 0449883) Conflicts: changelog.html
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import jenkins.model.RunAction2; | ||
import org.jfree.chart.ChartFactory; | ||
|
@@ -167,13 +168,14 @@ public Api getApi() { | |
* Gets the test result of the previous build, if it's recorded, or null. | ||
*/ | ||
public T getPreviousResult() { | ||
return (T)getPreviousResult(getClass()); | ||
return (T)getPreviousResult(getClass(), true); | ||
} | ||
|
||
private <U extends AbstractTestResultAction> U getPreviousResult(Class<U> type) { | ||
private <U extends AbstractTestResultAction> U getPreviousResult(Class<U> type, boolean eager) { | ||
Set<Integer> loadedBuilds = eager ? null : owner.getProject()._getRuns().getLoadedBuilds().keySet(); | ||
AbstractBuild<?,?> b = owner; | ||
while(true) { | ||
b = b.getPreviousBuild(); | ||
b = eager || loadedBuilds.contains(b.number - /* assuming there are no gaps */1) ? b.getPreviousBuild() : null; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jglick
Author
Member
|
||
if(b==null) | ||
return null; | ||
U r = b.getAction(type); | ||
|
@@ -256,7 +258,7 @@ private CategoryDataset buildDataSet(StaplerRequest req) { | |
|
||
DataSetBuilder<String,NumberOnlyBuildLabel> dsb = new DataSetBuilder<String,NumberOnlyBuildLabel>(); | ||
|
||
for( AbstractTestResultAction<?> a=this; a!=null; a=a.getPreviousResult(AbstractTestResultAction.class) ) { | ||
for (AbstractTestResultAction<?> a = this; a != null; a = a.getPreviousResult(AbstractTestResultAction.class, false)) { | ||
dsb.add( a.getFailCount(), "failed", new NumberOnlyBuildLabel(a.owner)); | ||
if(!failureOnly) { | ||
dsb.add( a.getSkipCount(), "skipped", new NumberOnlyBuildLabel(a.owner)); | ||
|
3 comments
on commit 8d81020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another issue looming is for those that just embed the Image in a different portal (outside of Jenkins)
e.g. ${JENKINS_URL}/job/commit/test/trend
If I understand correctly you may not get anything here as no builds may be loaded as you are not browsing using the job page which will not have loaded the state of previous jobs to show in the UI...
I can;t help feeling it would be simpler to always load the runs and to have a limit on the number that are loaded by this graph. - e.g. I want my trend graph to show the last 10 builds (assuming there are 140).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may not get anything here as no builds may be loaded
This is also possible, though probably unlikely since just browsing a list view including the job forces the last five or six builds to be loaded.
BTW if you visit the job index page, you are almost guaranteed to get at least the last thirty or so builds (assuming they form a contiguous version range), as the build history widget loads them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I thought this is not unlikely and has caused a definite regression and a major loss of functionality
There will be gaps as jenkins will if current builds are unstable always keep the last stable around.
100 -> stable
122 -> unstable
123 -> unstable
124 -> unstable
125 -> unstable.
All will be shown by the history (with a log rotator or 5 builds) - yet the stable version will not be returned here - causing the trending to be broken)
(unless I have read this incorrectly)
I would maybe guess that this build should have a getPreviousBuildNumber() function.