-
Notifications
You must be signed in to change notification settings - Fork 46
/
pre-upgrade-verify.groovy
58 lines (56 loc) · 2.24 KB
/
pre-upgrade-verify.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
salt = new com.mirantis.mk.Salt()
python = new com.mirantis.mk.Python()
common = new com.mirantis.mk.Common()
venvPepper = "venvPepper"
upgradeChecks = new com.mirantis.mcp.UpgradeChecks()
reportDir = 'reportDir/'
waList =['check_34406', 'check_34645', 'check_35705', 'check_35884', 'check_36461', 'check_36461_2', 'check_36960']
timeout(time: PIPELINE_TIMEOUT, unit: 'HOURS') {
node('python') {
try {
python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
def clusterName = salt.getPillar(venvPepper, 'I@salt:master', "_param:cluster_name").get("return")[0].values()[0]
def reportContent = ""
stage('Start checking work-arounds') {
for (wa in waList) {
//false - return status of check, true - raise exception
def waData = upgradeChecks."$wa"(salt, venvPepper, clusterName, false)
def reportTemplate = """
<tr>
<td class='row'>${waData.prodId}</td>
<td class='row'>${waData.isFixed}</td>
<td class='row'>${waData.waInfo}</td>
</tr>"""
reportContent = "${reportContent}${reportTemplate}"
}
}
stage('Generate report') {
sh "rm -rf ${reportDir}"
sh "mkdir -p ${reportDir}"
def reportHead = """<html>
<head>
<title>WA verify report</title>
</head>
<body>
<h1>WA verify report</h1>
<table border='1' cellpadding='5' cellspacing='0' style='border-collapse:collapse'>
<tr>
<th class='row'>Prod id</th>
<th class='row'>Status</th>
<th class='row'>Comment</th>
</tr>"""
def reportTail = """
</table>
</body>
</html>"""
writeFile file: "${reportDir}report.html", text: "${reportHead}${reportContent}${reportTail}"
archiveArtifacts artifacts: "${reportDir}/*"
}
} catch (Throwable e) {
// If there was an error or exception thrown, the build failed
currentBuild.result = "FAILURE"
currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
throw e
}
}
}