Show build cause on experimental build UI (#11128)
Changelog Drafter / update_draft_release (push) Waiting to run Details
Changelog Drafter / jenkins_io_draft (push) Waiting to run Details
Label conflicting PRs / main (push) Waiting to run Details

Co-authored-by: Kris Stern <krisstern@outlook.com>
This commit is contained in:
Jan Faracik 2025-10-01 16:28:24 +01:00 committed by GitHub
parent 481c7784e6
commit 4c310c5201
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 270 additions and 33 deletions

View File

@ -2621,7 +2621,7 @@ public class Functions {
for (Map.Entry<DetailGroup, List<Detail>> entry : result.entrySet()) {
List<Detail> detailList = entry.getValue();
detailList.sort(Comparator.comparingInt(Detail::getOrder));
detailList.sort(Comparator.comparingInt(Detail::getOrder).reversed());
}
return result;

View File

@ -24,6 +24,8 @@
package hudson.model;
import static hudson.Functions.getAvatar;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
@ -445,19 +447,30 @@ public abstract class Cause {
return userId != null ? userId : User.getUnknown().getId();
}
private User getUser() {
return userId == null ? null : User.getById(userId, false);
}
@Exported(visibility = 3)
public String getUserName() {
final User user = userId == null ? null : User.getById(userId, false);
final User user = getUser();
return user == null ? "anonymous" : user.getDisplayName();
}
@Restricted(DoNotUse.class) // for Jelly
@CheckForNull
public String getUserUrl() {
final User user = userId == null ? null : User.getById(userId, false);
final User user = getUser();
return user != null ? user.getUrl() : null;
}
@Restricted(DoNotUse.class) // for Jelly
@CheckForNull
public String getUserAvatar() {
final User user = getUser();
return user != null ? getAvatar(user, "48x48") : null;
}
@Override
public String getShortDescription() {
return Messages.Cause_UserIdCause_ShortDescription(getUserName());

View File

@ -120,6 +120,7 @@ import jenkins.model.Jenkins;
import jenkins.model.JenkinsLocationConfiguration;
import jenkins.model.RunAction2;
import jenkins.model.StandardArtifactManager;
import jenkins.model.details.CauseDetail;
import jenkins.model.details.Detail;
import jenkins.model.details.DetailFactory;
import jenkins.model.details.DurationDetail;
@ -2706,7 +2707,7 @@ public abstract class Run<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
}
@NonNull @Override public List<? extends Detail> createFor(@NonNull Run target) {
return List.of(new TimestampDetail(target), new DurationDetail(target));
return List.of(new CauseDetail(target), new TimestampDetail(target), new DurationDetail(target));
}
}
}

View File

@ -0,0 +1,29 @@
package jenkins.model.details;
import hudson.model.Cause;
import hudson.model.CauseAction;
import hudson.model.Run;
import java.util.Map;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
/**
* Displays the cause for the given run
*/
public class CauseDetail extends Detail {
public CauseDetail(Run<?, ?> run) {
super(run);
}
@Override
public int getOrder() {
return Integer.MAX_VALUE;
}
@Restricted(NoExternalUse.class)
public Map<Cause, Integer> getCauseCounts() {
CauseAction causeAction = getObject().getAction(CauseAction.class);
return causeAction.getCauseCounts();
}
}

View File

@ -60,9 +60,9 @@ public abstract class Detail implements ModelObject, IconSpec {
}
/**
* @return order in the group, zero is first, MAX_VALUE is any order
* @return order in the group, MAX_VALUE is first, zero is any order
*/
public int getOrder() {
return Integer.MAX_VALUE;
return 0;
}
}

View File

@ -10,4 +10,9 @@ public class TimestampDetail extends Detail {
public TimestampDetail(Run<?, ?> run) {
super(run);
}
@Override
public int getOrder() {
return Integer.MAX_VALUE - 1;
}
}

View File

@ -23,5 +23,5 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<span>${%blurb(it.addr, it.note)}</span>
<span>${it.shortDescription}</span>
</j:jelly>

View File

@ -1 +0,0 @@
blurb = Started by remote host {0} with note: {1}

View File

@ -1 +0,0 @@
blurb = Démarré par l''hôte distant {0} avec la note : {1}

View File

@ -0,0 +1,32 @@
<!--
The MIT License
Copyright (c) 2004-2011, Seiji Sogabe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout" xmlns:st="jelly:stapler">
<div class="jenkins-details__item">
<div class="jenkins-details__item__icon">
<l:icon src="symbol-cause" />
</div>
<st:include page="description.jelly" />
</div>
</j:jelly>

View File

@ -0,0 +1,64 @@
<!--
The MIT License
Copyright (c) 2004-2011, Seiji Sogabe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout">
<j:choose>
<j:when test="${it.upstreamUrl!=null and app.getItemByFullName(it.upstreamProject)!=null}">
<j:choose>
<j:when test="${app.getItemByFullName(it.upstreamProject).getBuildByNumber(it.upstreamBuild)!=null}">
<a class="jenkins-details__item"
href="${rootURL}/${it.upstreamUrl}${it.upstreamBuild.toString()}">
<div class="jenkins-details__item__icon">
<l:icon src="symbol-cause" />
</div>
<span>
${%started_by_project(app.getItemByFullName(it.upstreamProject).fullDisplayName,it.upstreamBuild.toString(),it.upstreamUrl,rootURL)}
</span>
</a>
</j:when>
<j:otherwise>
<a class="jenkins-details__item"
href="${rootURL}${it.upstreamUrl}">
<div class="jenkins-details__item__icon">
<l:icon src="symbol-cause" />
</div>
<span>
${%started_by_project_with_deleted_build(app.getItemByFullName(it.upstreamProject).fullDisplayName,it.upstreamBuild.toString(),it.upstreamUrl,rootURL)}
</span>
</a>
</j:otherwise>
</j:choose>
</j:when>
<j:otherwise>
<div class="jenkins-details__item">
<div class="jenkins-details__item__icon">
<l:icon src="symbol-cause" />
</div>
<span>
${it.shortDescription}
</span>
</div>
</j:otherwise>
</j:choose>
</j:jelly>

View File

@ -1,6 +1,6 @@
# The MIT License
#
# Copyright (c) 2004-, Kohsuke Kawaguchi, Sun Microsystems, Inc., and a number of other of contributors
# Copyright (c) 2004-2009, Sun Microsystems, Inc., Alan Harder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@ -20,4 +20,5 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
blurb=Startades av fjärrvärden {0} med följande anteckning: {1}
started_by_project=Started by upstream project {0} #{1}
started_by_project_with_deleted_build=Started by upstream project {0} #{1}

View File

@ -0,0 +1,48 @@
<!--
The MIT License
Copyright (c) 2004-2011, Seiji Sogabe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout">
<j:choose>
<j:when test="${it.userId != null}">
<a href="${rootURL + '/' + it.userUrl}" class="jenkins-details__item">
<div class="jenkins-details__item__icon">
<l:icon src="${it.userAvatar}" class="jenkins-avatar" />
</div>
<span>
${%started_by_user(it.userName)}
</span>
</a>
</j:when>
<j:otherwise>
<div class="jenkins-details__item">
<div class="jenkins-details__item__icon">
<l:icon src="symbol-person-circle" />
</div>
<span>
${%started_by_anonymous}
</span>
</div>
</j:otherwise>
</j:choose>
</j:jelly>

View File

@ -1,6 +1,6 @@
# The MIT License
#
# Copyright (c) 2004-, Kohsuke Kawaguchi, Sun Microsystems, Inc., and a number of other of contributors
# Copyright (c) 2004-2011, Seiji Sogabe
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@ -20,4 +20,5 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
blurb=Iniciado pelo hospedeiro remoto {0} com a nota: {1}
started_by_user=Started by {0}
started_by_anonymous=Started by anonymous user

View File

@ -24,14 +24,18 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<t:summary icon="symbol-trigger">
<j:forEach var="entry" items="${it.causeCounts.entrySet()}">
<p>
<st:include page="description.jelly" it="${entry.key}"/>
<j:if test="${entry.value > 1}">
<st:nbsp/>${%Ntimes(entry.value)}
</j:if>
</p>
</j:forEach>
</t:summary>
<l:userExperimentalFlag var="newBuildPage" flagClassName="jenkins.model.experimentalflags.NewBuildPageUserExperimentalFlag" />
<j:if test="${!newBuildPage}">
<t:summary icon="symbol-trigger">
<j:forEach var="entry" items="${it.causeCounts.entrySet()}">
<p>
<st:include page="description.jelly" it="${entry.key}"/>
<j:if test="${entry.value > 1}">
<st:nbsp/>${%Ntimes(entry.value)}
</j:if>
</p>
</j:forEach>
</t:summary>
</j:if>
</j:jelly>

View File

@ -0,0 +1,39 @@
<!--
The MIT License
Copyright (c) 2025 Jan Faracik
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout">
<j:forEach var="entry" items="${it.causeCounts.entrySet()}">
<st:include page="detail.jelly" it="${entry.key}" optional="true">
<div class="jenkins-details__item">
<div class="jenkins-details__item__icon">
<l:icon src="symbol-information-circle" />
</div>
<div>
<st:include page="description.jelly" it="${entry.key}" />
</div>
</div>
</st:include>
</j:forEach>
</j:jelly>

View File

@ -5,7 +5,7 @@ $icon-size: 1.125rem;
.jenkins-details {
display: flex;
align-items: center;
gap: 0.75rem 1.25rem;
gap: 0.25rem 1.25rem;
flex-wrap: wrap;
button.jenkins-details__item,
@ -37,7 +37,8 @@ $icon-size: 1.125rem;
width: $icon-size;
height: 2rem;
svg {
svg,
img {
width: $icon-size;
height: $icon-size;

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z" fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="32"/><path d="M216.32 334.44l114.45-69.14a10.89 10.89 0 000-18.6l-114.45-69.14a10.78 10.78 0 00-16.32 9.31v138.26a10.78 10.78 0 0016.32 9.31z" fill="currentColor"/></svg>

After

Width:  |  Height:  |  Size: 388 B