Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions core/src/main/java/hudson/model/Cause.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
import hudson.util.XStream2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import jenkins.model.Jenkins;
Expand Down Expand Up @@ -167,6 +170,7 @@
@Deprecated
private transient Cause upstreamCause;
private @NonNull List<Cause> upstreamCauses;
private transient Map<Cause, Integer> causeBag = new LinkedHashMap<>();

/**
* @deprecated since 2009-02-28
Expand All @@ -190,13 +194,29 @@
}
upstreamCauses.add(trim(c, MAX_DEPTH, traversed));
}
fillCauseBag();
}

private UpstreamCause(String upstreamProject, int upstreamBuild, String upstreamUrl, @NonNull List<Cause> upstreamCauses) {
this.upstreamProject = upstreamProject;
this.upstreamBuild = upstreamBuild;
this.upstreamUrl = upstreamUrl;
this.upstreamCauses = upstreamCauses;
fillCauseBag();
}

private void fillCauseBag() {
if (causeBag == null) {
causeBag = new LinkedHashMap<>();
}
for (Cause c : upstreamCauses) {
causeBag.compute(c, (unused, cnt) -> cnt == null ? 1 : cnt + 1);

Check warning on line 213 in core/src/main/java/hudson/model/Cause.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 213 is only partially covered, one branch is missing
}
}

@Restricted(DoNotUse.class) // used from Jelly
public Map<Cause, Integer> getCauseCounts() {
return Collections.unmodifiableMap(causeBag);
}

@Override
Expand Down Expand Up @@ -351,6 +371,7 @@
uc.upstreamCause = null;
OldDataMonitor.report(context, "1.288");
}
uc.fillCauseBag();
}
}

Expand All @@ -359,6 +380,16 @@
return "(deeply nested causes)";
}

@Override
public int hashCode() {
return 11;
}

@Override
public boolean equals(Object obj) {
return obj instanceof DeeplyNestedUpstreamCause;

Check warning on line 390 in core/src/main/java/hudson/model/Cause.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 390 is not covered by tests
}

@Override public String toString() {
return "JENKINS-14814";
}
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/hudson/model/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -2399,6 +2399,14 @@
return Collections.emptyList();
}

@Restricted(DoNotUse.class) // used from Jelly
public final Map<Cause, Integer> getCauseCounts() {
CauseAction ca = getAction(CauseAction.class);
if (ca != null)

Check warning on line 2405 in core/src/main/java/hudson/model/Queue.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 2405 is only partially covered, one branch is missing
return ca.getCauseCounts();
return Collections.emptyMap();

Check warning on line 2407 in core/src/main/java/hudson/model/Queue.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 2407 is not covered by tests
}

@Restricted(DoNotUse.class) // used from Jelly
@Override
public String getCausesDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ THE SOFTWARE.
</j:otherwise>
</j:choose>

<j:if test="${!it.upstreamCauses.isEmpty()}">
<j:set var="causeCounts" value="${it.causeCounts}" />
<j:if test="${!causeCounts.isEmpty()}">
<br />${%caused_by}
<ul>
<j:forEach var="c" items="${it.upstreamCauses}">
<li><st:include page="description.jelly" it="${c}" /></li>
<j:forEach var="c" items="${causeCounts.entrySet()}">
<li><st:include page="description.jelly" it="${c.key}" />
<j:if test="${c.value > 1}"><st:nbsp/>${%Ntimes(c.value)}</j:if><br/>
</li>
</j:forEach>
</ul>
</j:if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
started_by_project=Started by upstream project <a class="model-link model-link--float" href="{3}/{2}">{0}</a> build number <a class="model-link model-link--float" href="{3}/{2}{1}/">{1}</a>
started_by_project_with_deleted_build=Started by upstream project <a class="model-link model-link--float" href="{3}/{2}">{0}</a> build number {1}
caused_by=originally caused by:
Ntimes=({0} times)
7 changes: 6 additions & 1 deletion core/src/main/resources/lib/hudson/queue.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ THE SOFTWARE.
<j:set var="stuck" value="${item.isStuck()}"/>
<j:choose>
<j:when test="${h.hasPermission(item.task,item.task.READ)}">
<j:set var="causeDescription">
<j:forEach var="entry" items="${item.causeCounts.entrySet()}">${entry.key.shortDescription}<j:if test="${entry.value > 1}"><st:nbsp/>${%Ntimes(entry.value)}</j:if><br/>
</j:forEach>${item.why} ${item.params}
${%WaitingFor(item.inQueueForString)}
</j:set>
<a href="${rootURL}/${item.task.url}" class="model-link inside tl-tr"
tooltip="${item.causesDescription} ${item.why} ${item.params} \n ${%WaitingFor(item.inQueueForString)}"
data-html-tooltip="${causeDescription}"
data-tooltip-append-to-parent="true">
<l:breakable value="${item.displayName}"/>
</a>
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/lib/hudson/queue.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ Build\ Queue=Build Queue{0,choice,0#|0< ({0,number})}
Filtered\ Build\ Queue=Filtered Build Queue{0,choice,0#|0< ({0,number})}
WaitingFor=Waiting for {0}
confirm=Are you sure you want to cancel the queued run of {0}?
Ntimes=({0} times)
2 changes: 1 addition & 1 deletion test/src/test/java/hudson/model/QueueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ private String buildAndExtractTooltipAttribute() throws Exception {

HtmlPage page = wc.goTo("");

page.executeJavaScript("document.querySelector('#buildQueue a[tooltip]:not([tooltip=\"\"])')._tippy.show()");
page.executeJavaScript("document.querySelector('#buildQueue a[data-html-tooltip]:not([data-html-tooltip=\"\"])')._tippy.show()");
wc.waitForBackgroundJavaScript(1000);
ScriptResult result = page.executeJavaScript("document.querySelector('.tippy-content').innerHTML;");

Expand Down
Loading