Skip to content

Commit

Permalink
[FIXED JENKINS-31487] (#2542)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthewreiter authored and daniel-beck committed Sep 18, 2016
1 parent fbb4dc0 commit 0268b98
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/widgets/BuildHistoryWidget.java
Expand Up @@ -77,6 +77,6 @@ public HistoryPageFilter getHistoryPageFilter() {
historyPageFilter.add(baseList, getQueuedItems());
historyPageFilter.widget = this;

return historyPageFilter;
return updateFirstTransientBuildKey(historyPageFilter);
}
}
17 changes: 15 additions & 2 deletions core/src/main/java/hudson/widgets/HistoryWidget.java
Expand Up @@ -114,6 +114,20 @@ public String getFirstTransientBuildKey() {
return firstTransientBuildKey;
}

/**
* Calculates the first transient build record. Everything >= this will be discarded when AJAX call is made.
*
* @param historyPageFilter
* The history page filter containing the list of builds.
* @return
* The history page filter that was passed in.
*/
@SuppressWarnings("unchecked")
protected HistoryPageFilter updateFirstTransientBuildKey(HistoryPageFilter historyPageFilter) {
updateFirstTransientBuildKey(historyPageFilter.runs);
return historyPageFilter;
}

private Iterable<HistoryPageEntry<T>> updateFirstTransientBuildKey(Iterable<HistoryPageEntry<T>> source) {
String key=null;
for (HistoryPageEntry<T> t : source) {
Expand Down Expand Up @@ -166,7 +180,7 @@ public HistoryPageFilter getHistoryPageFilter() {

historyPageFilter.add(baseList);
historyPageFilter.widget = this;
return historyPageFilter;
return updateFirstTransientBuildKey(historyPageFilter);
}

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

HistoryPageFilter page = getHistoryPageFilter();
updateFirstTransientBuildKey(page.runs);
req.getView(page,"ajaxBuildHistory.jelly").forward(req,rsp);
}

Expand Down
Expand Up @@ -119,6 +119,6 @@ THE SOFTWARE.
</l:pane>
</div>
<script defer="true">
updateBuildHistory("${it.baseUrl}/buildHistory/ajax",${it.owner.nextBuildNumber});
updateBuildHistory("${it.baseUrl}/buildHistory/ajax", ${it.nextBuildNumberToFetch ?: it.owner.nextBuildNumber});
</script>
</j:jelly>

0 comments on commit 0268b98

Please sign in to comment.