Skip to content

Commit 0268b98

Browse files
matthewreiterdaniel-beck
authored andcommittedSep 18, 2016
There were two issues preventing the build history from updating properly: 1) The next build number being fetched wasn't taking into account running builds, so any builds already running when the page is refreshed would be ignored. The fix was to use nextBuildNumberToFetch if it is available (which is the case if there are running builds) and to fall back to the next build otherwise. 2) The first transient build key (used to clear out builds from the history that are being updated) wasn't being set when the page first loads. This was fixed by making getHistoryPageFilter calculate the value so that it happens in all cases rather than just during the ajax call.
1 parent fbb4dc0 commit 0268b98

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed
 

‎core/src/main/java/hudson/widgets/BuildHistoryWidget.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ public HistoryPageFilter getHistoryPageFilter() {
7777
historyPageFilter.add(baseList, getQueuedItems());
7878
historyPageFilter.widget = this;
7979

80-
return historyPageFilter;
80+
return updateFirstTransientBuildKey(historyPageFilter);
8181
}
8282
}

‎core/src/main/java/hudson/widgets/HistoryWidget.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,20 @@ public String getFirstTransientBuildKey() {
114114
return firstTransientBuildKey;
115115
}
116116

117+
/**
118+
* Calculates the first transient build record. Everything >= this will be discarded when AJAX call is made.
119+
*
120+
* @param historyPageFilter
121+
* The history page filter containing the list of builds.
122+
* @return
123+
* The history page filter that was passed in.
124+
*/
125+
@SuppressWarnings("unchecked")
126+
protected HistoryPageFilter updateFirstTransientBuildKey(HistoryPageFilter historyPageFilter) {
127+
updateFirstTransientBuildKey(historyPageFilter.runs);
128+
return historyPageFilter;
129+
}
130+
117131
private Iterable<HistoryPageEntry<T>> updateFirstTransientBuildKey(Iterable<HistoryPageEntry<T>> source) {
118132
String key=null;
119133
for (HistoryPageEntry<T> t : source) {
@@ -166,7 +180,7 @@ public HistoryPageFilter getHistoryPageFilter() {
166180

167181
historyPageFilter.add(baseList);
168182
historyPageFilter.widget = this;
169-
return historyPageFilter;
183+
return updateFirstTransientBuildKey(historyPageFilter);
170184
}
171185

172186
protected HistoryPageFilter<T> newPageFilter() {
@@ -238,7 +252,6 @@ public void doAjax( StaplerRequest req, StaplerResponse rsp,
238252
}
239253

240254
HistoryPageFilter page = getHistoryPageFilter();
241-
updateFirstTransientBuildKey(page.runs);
242255
req.getView(page,"ajaxBuildHistory.jelly").forward(req,rsp);
243256
}
244257

‎core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,6 @@ THE SOFTWARE.
119119
</l:pane>
120120
</div>
121121
<script defer="true">
122-
updateBuildHistory("${it.baseUrl}/buildHistory/ajax",${it.owner.nextBuildNumber});
122+
updateBuildHistory("${it.baseUrl}/buildHistory/ajax", ${it.nextBuildNumberToFetch ?: it.owner.nextBuildNumber});
123123
</script>
124124
</j:jelly>

0 commit comments

Comments
 (0)
Please sign in to comment.