-
Notifications
You must be signed in to change notification settings - Fork 22
/
summary.groovy
58 lines (51 loc) · 1.58 KB
/
summary.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package org.jenkinsci.plugins.cloudstats.CloudAction
import hudson.model.HealthReport
import org.jenkinsci.plugins.cloudstats.ActivityIndex
import org.jenkinsci.plugins.cloudstats.CloudAction
import org.jenkinsci.plugins.cloudstats.Health
import org.jenkinsci.plugins.cloudstats.ProvisioningActivity
def l = namespace(lib.LayoutTagLib)
def st = namespace("jelly:stapler")
def cs = namespace("lib/cloudstats")
// Pull vars from binding into script for type safety / code assistance
CloudAction action = my
ActivityIndex index = action.cloudStatistics.index
Health.Report report = index.cloudHealth(action.cloud.name).current
HealthReport hr = report.weather
h2 {
l.icon("class": "${hr.iconClassName} icon-md", alt: hr.score + "")
st.nbsp()
text("${action.displayName} (Health ${report})")
}
int provisioning = launching = operating = 0
def noteworthy = []
index.forCloud(action.cloud.name).each {
if (it.currentPhase == ProvisioningActivity.Phase.PROVISIONING) {
provisioning++
} else if (it.currentPhase == ProvisioningActivity.Phase.LAUNCHING) {
launching++
} else if (it.currentPhase == ProvisioningActivity.Phase.OPERATING) {
operating++
}
if (it.status != ProvisioningActivity.Status.OK) {
noteworthy << it
}
}
table {
tr {
th("Operation")
td(operating)
}
tr {
th("Provisioning")
td(provisioning)
}
tr {
th("Launching")
td(launching)
}
}
if (!noteworthy.empty) {
h2("Recent Problems")
cs.attempts(activities: noteworthy, stats: action.cloudStatistics)
}