Jenkins如何更新Build Jobs的天气报告? [英] How Jenkins updates the Weather report for Build Jobs?

查看:323
本文介绍了Jenkins如何更新Build Jobs的天气报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jenkins遵循什么机制/统计信息来更新有关构建作业"的天气信息?

解决方案

查看

该代码表明,如果成功构建的比例超过80%,您将看到晴朗的天气图标.

如果成功构建在60%-79%之间,则会看到名为health-60to79的图像.

...

您可以在 https://github.com/jenkinsci中找到图像/jenkins/blob/master/war/images .它们分别命名为health-00to19.svghealth-20to39.svghealth-40to59.svghealth-60to79.svghealth-80plus.svg.

HealthReport是用于更新天气图标的机制

public HealthReport(int score, String iconUrl, Localizable description) {
    this.score = score;
    if (score <= 20) {
        this.iconClassName = HEALTH_0_TO_20;
    } else if (score <= 40) {
        this.iconClassName = HEALTH_21_TO_40;
    } else if (score <= 60) {
        this.iconClassName = HEALTH_41_TO_60;
    } else if (score <= 80) {
        this.iconClassName = HEALTH_61_TO_80;
    } else {
        this.iconClassName = HEALTH_OVER_80;
    }
    if (iconUrl == null) {
        if (score <= 20) {
            this.iconUrl = HEALTH_0_TO_20_IMG;
        } else if (score <= 40) {
            this.iconUrl = HEALTH_21_TO_40_IMG;
        } else if (score <= 60) {
            this.iconUrl = HEALTH_41_TO_60_IMG;
        } else if (score <= 80) {
            this.iconUrl = HEALTH_61_TO_80_IMG;
        } else {
            this.iconUrl = HEALTH_OVER_80_IMG;
        }
    } else {
        this.iconUrl = iconUrl;
    }
    this.description = null;
    setLocalizibleDescription(description);
}

What mechanism/statistics does Jenkins follow to update the Weather information regarding the Build Jobs?

解决方案

Check out https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/HealthReport.java

You can then find the following code there:

// These are now 0-20, 21-40, 41-60, 61-80, 81+ but filenames unchanged for compatibility
private static final String HEALTH_OVER_80 = "icon-health-80plus";
private static final String HEALTH_61_TO_80 = "icon-health-60to79";
private static final String HEALTH_41_TO_60 = "icon-health-40to59";
private static final String HEALTH_21_TO_40 = "icon-health-20to39";
private static final String HEALTH_0_TO_20 = "icon-health-00to19";

private static final String HEALTH_OVER_80_IMG = "health-80plus.png";
private static final String HEALTH_61_TO_80_IMG = "health-60to79.png";
private static final String HEALTH_41_TO_60_IMG = "health-40to59.png";
private static final String HEALTH_21_TO_40_IMG = "health-20to39.png";
private static final String HEALTH_0_TO_20_IMG = "health-00to19.png";
private static final String HEALTH_UNKNOWN_IMG = "empty.png";

The code indicates that if your successful builds are over 80%, you will see the sunny weather icon.

If your successful builds is between 60%-79%, you will see see an image named health-60to79.

...

You can find the images at https://github.com/jenkinsci/jenkins/blob/master/war/images. They are named health-00to19.svg, health-20to39.svg, health-40to59.svg, health-60to79.svg, and health-80plus.svg.

HealthReport is the mechanism used to update the weather icon

public HealthReport(int score, String iconUrl, Localizable description) {
    this.score = score;
    if (score <= 20) {
        this.iconClassName = HEALTH_0_TO_20;
    } else if (score <= 40) {
        this.iconClassName = HEALTH_21_TO_40;
    } else if (score <= 60) {
        this.iconClassName = HEALTH_41_TO_60;
    } else if (score <= 80) {
        this.iconClassName = HEALTH_61_TO_80;
    } else {
        this.iconClassName = HEALTH_OVER_80;
    }
    if (iconUrl == null) {
        if (score <= 20) {
            this.iconUrl = HEALTH_0_TO_20_IMG;
        } else if (score <= 40) {
            this.iconUrl = HEALTH_21_TO_40_IMG;
        } else if (score <= 60) {
            this.iconUrl = HEALTH_41_TO_60_IMG;
        } else if (score <= 80) {
            this.iconUrl = HEALTH_61_TO_80_IMG;
        } else {
            this.iconUrl = HEALTH_OVER_80_IMG;
        }
    } else {
        this.iconUrl = iconUrl;
    }
    this.description = null;
    setLocalizibleDescription(description);
}

这篇关于Jenkins如何更新Build Jobs的天气报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆