-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathosp-results-notifier.groovy
125 lines (106 loc) · 4.35 KB
/
osp-results-notifier.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
This workflow performs the following tasks
- Process the Ceph - OSP integration test result message posted.
- If the test run was successful update the recipe file
- Send an email to cephci@redhat.com about the test results
*/
def sendEMail(def bodyMap) {
/*
This method posts an email using the provided arguments.
Args:
bodyMap (map): Map that contains the following keys
artifact: Information of build used for testing
test: Details about the test
run: Details about the run
*/
def htmlMail = readFile("pipeline/vars/emailable-report.html")
htmlMail += "<body>"
htmlMail += "<h3><u>Summary</u></h3>"
htmlMail += "<table>"
htmlMail += "<tr><td>Product</td><td>${bodyMap['artifact']['nvr']}</td></tr>"
htmlMail += "<tr><td>Ceph version</td><td>${bodyMap['artifact']['ceph-version']}</td></tr>"
htmlMail += "<tr><td>Composes</td><td>${bodyMap['artifact']['composes']}</td></tr>"
htmlMail += "<tr><td>Image</td><td>${bodyMap['artifact']['repository']}</td></tr>"
htmlMail += "<tr><td>OSP version</td><td>${bodyMap['nvr']}</td></tr>"
htmlMail += "<tr><td>OSP Integration status</td><td>${bodyMap['test']['result']}</td></tr>"
htmlMail += "<tr><td>Logs</td><td>${bodyMap['run']['log']}</td></tr>"
htmlMail += "</table> <br /> </body> </html>"
emailext (
mimeType: 'text/html',
subject: "[Test Report] ${bodyMap['nvr']} - ${bodyMap['artifact']['nvr']} InterOp test results.",
body: "${htmlMail}",
from: "cephci@redhat.com",
to: "cephci@redhat.com"
)
}
node('rhel-9-medium || ceph-qe-ci') {
stage('prepareJenkinsNode') {
if ( !params.CI_MESSAGE?.trim() ) {
currentBuild.result = 'ABORTED'
error('No test execution results to process.')
}
checkout(
scm: [
$class: 'GitSCM',
branches: [[name: 'origin/master']],
extensions: [[
$class: 'CleanBeforeCheckout',
deleteUntrackedNestedRepositories: true
], [
$class: 'WipeWorkspace'
], [
$class: 'CloneOption',
depth: 1,
noTags: true,
shallow: true,
timeout: 10,
reference: ''
]],
userRemoteConfigs: [[
url: 'https://github.com/red-hat-storage/cephci.git'
]]
],
changelog: false,
poll: false
)
}
stage('publish') {
def argMap = readJSON text: params.CI_MESSAGE
sendEMail(argMap)
if ( argMap['test']['result'] == 'FAILED' ) {
println('New build failed to pass tests.')
return
}
timeout(unit: "MINUTES", time: 10) {
sh '''
if [ ! -d /ceph/cephci-jenkins ]; then
sudo mkdir -p /ceph
sudo mount -t nfs -o sec=sys,nfsvers=4.1 reesi004.ceph.redhat.com:/ /ceph
fi
'''
}
def ospMap = [
"repository": argMap['artifact']['repository'],
"composes": argMap['artifact']['composes'],
"ceph-version": argMap['artifact']['ceph-version']
]
def nvr = argMap['artifact']['nvr']
def rhCephVersion = nvr.split('-')[1]
def majorVersion = rhCephVersion.split('\\.')[0]
def minorVersion = rhCephVersion.split('\\.')[1]
def sharedLib = load("${env.WORKSPACE}/pipeline/vars/v3.groovy")
def recipeMap = sharedLib.readFromReleaseFile(majorVersion, minorVersion)
if ( recipeMap?.osp ) {
def existingCephVersion = recipeMap['osp']['ceph-version']
def newCephVersion = ospMap['ceph-version']
def rst = sharedLib.compareCephVersion(existingCephVersion, newCephVersion)
if ( rst != 1 ) {
println("Tests were not executed on a newer development version.")
sharedLib.unSetLock(majorVersion, minorVersion)
return
}
}
recipeMap['osp'] = ospMap
sharedLib.writeToReleaseFile(majorVersion, minorVersion, recipeMap)
}
}