[JENKINS-75350] Displays plugin health score in Plugin Manager (#10351)

Co-authored-by: Markus Winter <m.winter@sap.com>
Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com>
Co-authored-by: Daniel Beck <1831569+daniel-beck@users.noreply.github.com>
Co-authored-by: Daniel Beck <daniel-beck@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2025-04-30 21:15:23 +01:00
1 parent d1fd53784a
commit d70bc2e623
18 files changed
+199 -6

No files matched your search

@@ -222,6 +222,8 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
*/
private static Set<String> CORE_ONLY_DEPENDANT = Set.of("jenkins-core");
private Integer healthScore;
/**
* Set the list of components that depend on this plugin.
* @param dependents The list of components that depend on this plugin.
@@ -423,6 +425,32 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
}
@Restricted(NoExternalUse.class) // Jelly use only
public Integer getHealthScore() {
if (this.healthScore == null) {
this.healthScore = getInfoFromAllSites().stream()
.filter(Objects::nonNull)
.filter(p -> p.healthScore != null)
.findFirst()
.map(plugin -> plugin.healthScore)
.orElse(null);
}
return this.healthScore;
}
@Restricted(NoExternalUse.class)
public static String getHealthScoreClassForScore(int score) {
if (score > 80) return "top";
if (score > 60) return "middle";
return "bottom";
}
@Restricted(NoExternalUse.class) // Jelly use only
public String getHealthScoreClass() {
if (this.healthScore == null) return null;
return getHealthScoreClassForScore(this.healthScore);
}
@ExportedBean
public static final class Dependency {
@Exported