Skip to content

Commit

Permalink
[JENKINS-68320] Fix: use modern Jenkins icon for failed promotions in…
Browse files Browse the repository at this point in the history
… build history panel (#187)

* Remove references to non-existent error.png icon

* Remove references to non-existent error.png icon

* Remove references to non-existent error.png icon

* Remove references to non-existent error.png icon

* Remove references to non-existent error.png icon

* Remove references to non-existent error.png icon

---------

Co-authored-by: Mark Waite <[email protected]>
Co-authored-by: Alexander Brandes <[email protected]>
  • Loading branch information
3 people authored Jan 4, 2024
1 parent 5327e6e commit 597f5c6
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
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 @@ public PromotionProcess getProcess() {

/**
* 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() {

This comment has been minimized.

Copy link
@owengo

owengo Aug 20, 2024

This change broke the delivery-pipeline-plugin:
java.lang.NoSuchMethodError: 'java.lang.String hudson.plugins.promoted_builds.Status.getIcon(java.lang.String)'
at PluginClassLoader for delivery-pipeline-plugin//se.diabol.jenkins.pipeline.domain.status.promotion.PromotionStatusProvider$PromotionStatusWrapper.getIcon(PromotionStatusProvider.java:129)
at PluginClassLoader for delivery-pipeline-plugin//se.diabol.jenkins.pipeline.domain.status.promotion.PromotionStatusProvider.buildNewPromotionStatus(PromotionStatusProvider.java:82)
at PluginClassLoader for delivery-pipeline-plugin//

This comment has been minimized.

Copy link
@MarkEWaite

MarkEWaite Aug 20, 2024

Author Contributor

Thanks for reporting that error. The change to fix that error was merged 5 months ago to the delivery pipeline plugin master branch but has not been released because there is no maintainer of the delivery pipeline plugin.

Since you're a user of the delivery pipeline plugin, would you be willing to test drive the plugin build from the master branch to confirm that it resolves the issue? I've attached a zip file of the plugin build from the master branch or you can download a fresh build from the Jenkins job at https://ci.jenkins.io/job/Plugins/job/delivery-pipeline-plugin/job/master/

delivery-pipeline-plugin-hpi.zip

This comment has been minimized.

Copy link
@owengo

owengo Aug 20, 2024

Oh it's great the project has been forked and is built again. Could you please accept the PR Diabol/delivery-pipeline-plugin#347 , it fixes an annoying missing image for the "play" button. My local build ( which we are using on our jenkins instance ) has the fix.

I confirm that a build of the master from https://github.com/jenkinsci/delivery-pipeline-plugin + PR 347 fixes both the image problem and the getIcon() problem

This comment has been minimized.

Copy link
@MarkEWaite

MarkEWaite Aug 20, 2024

Author Contributor

I don't have permissions on that repository. Share your comment in that other repository in hopes that they will release a new version.

If they don't respond, then you could propose to adopt the plugin and then you could create the release yourself. Active users of a plugin are often the best maintainers of that plugin.

String baseName;

PromotionProcess p = getProcess();
Expand All @@ -130,7 +129,7 @@ public String getIcon(String size) {
} 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

0 comments on commit 597f5c6

Please sign in to comment.