-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnvironmentInventory.groovy
43 lines (42 loc) · 1.27 KB
/
EnvironmentInventory.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
project "Test", {
procedure "Environment Inventory", resourceName: 'local', {
step "Get Inventory", shell: 'ectool evalDsl --dslFile "{0}"', command: '''\
import groovy.json.*
def rows=[]
def fields = [
"serviceName",
"projectName",
"environmentName",
"artifactName",
"artifactVersion",
"status"
]
getProjects().each { proj ->
if (proj.pluginKey==null) {
getEnvironments(projectName: proj.projectName).each { env ->
getEnvironmentInventoryItems(projectName: proj.projectName, environmentName: env.environmentName).each { invItem ->
def row = [:]
fields.each { field ->
if (field == "serviceName") {
row[field] = """<img src=\\\\"../../../flow/public/app/assets/img/svg-icons/icon-service.svg\\\\" height=\\\\"20\\\\" width=\\\\"20\\\\"> """ + invItem[field]
} else {
row[field] = invItem[field]
}
}
rows << row
}
}
}
}
property "/myJob/inventory", value: JsonOutput.toJson(rows)
'''.stripIndent()
step 'Generate Report',
subproject : '/plugins/EF-ReportingTools/project',
subprocedure : 'json2table',
actualParameter : [
jsonData: '''$[/myJob/inventory]''',
reportName: "Environment Inventory",
columnOrnamentation: ""
]
}
}