Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-68320] Fix: use modern Jenkins icon for failed promotions in build history panel #187

Merged
merged 10 commits into from
Jan 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public List<String> getPromotionIcons(final Item item) {
for (Status s : a.getPromotions()) {
PromotionProcess process = s.getProcess();
if (process !=null && process.isVisible()){
icons.add(s.getIcon("16px"));
icons.add(s.getIcon());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public final class PromotionProcess extends AbstractProject<PromotionProcess,Pro
new DescribableList<PromotionCondition, PromotionConditionDescriptor>(this);
/**
* The icon that represents this promotion process. This is the name of
* the GIF icon that can be found in ${rootURL}/plugin/promoted-builds/icons/16x16/
* and ${rootURL}/plugin/promoted-builds/icons/32x32/, e.g. <code>"star-gold"</code>.
* the SVG icon that can be found in ${rootURL}/plugin/promoted-builds/icons/,
* e.g. <code>"star-gold"</code>.
*/
public String icon;

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/hudson/plugins/promoted_builds/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@

/**
* Gets the icon that should represent this promotion (that is potentially attempted but failed.)
* @param size size of the icon, will be used in the icon path
* @return Path to the icon in resources
* @return Path to the SVG icon in resources or l:icon class name
*/
@NonNull
public String getIcon(String size) {
public String getIcon() {
String baseName;

PromotionProcess p = getProcess();
Expand All @@ -130,7 +129,7 @@
} else {
Promotion l = getLast();
if (l!=null && l.getResult()!= Result.SUCCESS) {
return Jenkins.RESOURCE_PATH+"/images/"+size+"/error.png";
return "icon-red";

Check warning on line 132 in src/main/java/hudson/plugins/promoted_builds/Status.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 132 is not covered by tests
}
baseName = p.getIcon();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public final class JobDslPromotionProcess {
private String name;
/**
* The icon that represents this promotion process. This is the name of
* the GIF icon that can be found in ${rootURL}/plugin/promoted-builds/icons/16x16/
* and ${rootURL}/plugin/promoted-builds/icons/32x32/, e.g. <code>"star-gold"</code>.
* the SVG icon that can be found in ${rootURL}/plugin/promoted-builds/icons/,
* e.g. <code>"star-gold"</code>.
*/
private String icon;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core">
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout">
<td>
<j:forEach var="c" items="${it.getPromotionIcons(job)}">
<img src="${rootURL}${c}" border="0"/>
<j:choose>
<j:when test="${c == 'icon-red'}">
<l:icon class="icon-red icon-sm"/>
</j:when>
<j:otherwise>
<img src="${rootURL}${c}" border="0"/>
</j:otherwise>
</j:choose>
</j:forEach>
</td>
</j:jelly>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core">
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout">
<j:if test="${it.hasPromotion()}">
<j:forEach var="status" items="${it.getPromotions()}">
<j:if test="${status.getProcess()!=null and status.getProcess().isVisible()}">
<a href="${link}promotion/">
<img width="16" height="16"
title="${status.name}"
src="${rootURL}${status.getIcon('16px')}"/>
</a>
<a href="${link}promotion/">
<j:choose>
<j:when test="${status.getIcon() == 'icon-red'}">
<l:icon class="icon-red icon-sm" tooltip="${status.name}" style="vertical-align: middle"/>
</j:when>
<j:otherwise>
<img width="16" height="16"
title="${status.name}"
src="${rootURL}${status.getIcon()}"/>
</j:otherwise>
</j:choose>
</a>
</j:if>
</j:forEach>
</j:if>
Expand Down
Loading