mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-28 03:55:20 +00:00
[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:
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
|
||||
|
||||
Reference in new issue
Block a user