-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathJenkinsfile-omec-install-Nucleus-vnf.groovy
175 lines (152 loc) · 6.54 KB
/
Jenkinsfile-omec-install-Nucleus-vnf.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// Copyright 2019-present Open Networking Foundation
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
node("${params.buildNode}") {
def ghRepository = 'omec-project/Nucleus'
def install_path = '/home/jenkins'
def base_path = '/var/log/cicd'
def base_folder = 'install'
def base_log_dir = "${base_path}/${base_folder}"
def action_make = '_make'
def action_install = '_install'
def stdout_ext = '.stdout.log'
def stderr_ext = '.stderr.log'
def mme_base_make_stdout_log = "cicd_Nucleus" + "${action_make}${stdout_ext}"
def mme_base_make_stderr_log = "cicd_Nucleus" + "${action_make}${stderr_ext}"
def mme_base_install_stdout_log = "cicd_Nucleus" + "${action_install}${stdout_ext}"
def mme_base_install_stderr_log = "cicd_Nucleus" + "${action_install}${stderr_ext}"
def mme_make_stdout_log = "${base_log_dir}/${mme_base_make_stdout_log}"
def mme_make_stderr_log = "${base_log_dir}/${mme_base_make_stderr_log}"
def mme_install_stdout_log = "${base_log_dir}/${mme_base_install_stdout_log}"
def mme_install_stderr_log = "${base_log_dir}/${mme_base_install_stderr_log}"
timeout (60) {
try {
echo "${params}"
stage("VMs check") {
timeout(1) {
waitUntil {
running_vms = sh returnStdout: true, script: """
virsh list --all
"""
echo "Running VMs: ${running_vms}"
return true
}
}
timeout(1) {
waitUntil {
running_vms = sh returnStdout: true, script: """
virsh list --all | grep c3po-mme1 | grep -i running | wc -l
"""
return running_vms.toInteger() == 1
}
}
// Clean all logs
sh returnStdout: true, script: """
ssh c3po-mme1 '
if [ ! -d "${base_log_dir}" ]; then mkdir -p ${base_log_dir}; fi
rm -fr ${base_log_dir}/*
'
"""
}
stage("Install MME") {
timeout(10) {
waitUntil {
c3po_mme_kill_output = sh returnStdout: true, script: """
ssh c3po-mme1 '
ps -e | grep -P "(mme|s11|s1ap|s6a)-app" | grep -v grep || echo "no running process found"
if pgrep -f [m]me-app; then pkill -f [m]me-app; fi
sleep 1
if pgrep -f [s]1ap-app; then pkill -f [s]1ap-app; fi
sleep 1
if pgrep -f [s]11-app; then pkill -f [s]11-app; fi
sleep 1
if pgrep -f [s]6a-app; then pkill -f [s]6a-app; fi
sleep 5
ps -e | grep -P "(mme|s11|s1ap|s6a)-app" | grep -v grep && exit 1 || echo "no running process found"
'
"""
echo "${c3po_mme_kill_output}"
c3po_mme1_output = sh returnStdout: true, script: """
ssh c3po-mme1 '
cd ${install_path}
rm -rf Nucleus
git clone https://github.com/omec-project/Nucleus.git -b ${params.branch} || exit 1
cd Nucleus
if [ ${params.ghprbGhRepository} = ${ghRepository} ]; then
# Clone repo.
git checkout ${params.ghprbTargetBranch}
git fetch origin pull/${params.ghprbPullId}/head:jenkins_test || exit 1
git checkout jenkins_test
git log -1
# Check that the merge base between target branch and PR is target branch HEAD.
if [[ \$(git merge-base jenkins_test ${params.ghprbTargetBranch}) != \$(git rev-parse ${params.ghprbTargetBranch}) ]]; then
message=(
""
"*******************************************"
"* *"
"* PR is not based on current ${params.ghprbTargetBranch} HEAD. *"
"* Please rebase your code on ${params.ghprbTargetBranch}. *"
"* *"
"*******************************************"
""
)
printf "%s\\n" "\${message[@]}"
exit 1
fi
fi
cp -f ${install_path}/Nucleus/.ci/config/mme.json ${install_path}/Nucleus/src/mme-app/conf/mme.json
cp -f ${install_path}/Nucleus/.ci/config/s1ap.json ${install_path}/Nucleus/src/s1ap/conf/s1ap.json
cp -f ${install_path}/Nucleus/.ci/config/s11.json ${install_path}/Nucleus/src/s11/conf/s11.json
cp -f ${install_path}/Nucleus/.ci/config/s6a.json ${install_path}/Nucleus/src/s6a/conf/s6a.json
cp -f ${install_path}/Nucleus/.ci/config/s6a_fd.conf ${install_path}/Nucleus/src/s6a/conf/s6a_fd.conf
'
"""
echo "${c3po_mme1_output}"
return true
}
sh returnStdout: true, script: """
ssh c3po-mme1 '
cd ${install_path}/Nucleus
make clean || exit 1
make 1>${mme_make_stdout_log} 2>${mme_make_stderr_log} || exit 1
make install 1>${mme_install_stdout_log} 2>${mme_install_stderr_log}
'
"""
sh returnStdout: true, script: """
ssh c3po-mme1 '
cd ${install_path}/Nucleus/target/conf
./make_certs.sh mme localdomain
'
"""
}
}
currentBuild.result = 'SUCCESS'
} catch (err) {
currentBuild.result = 'FAILURE'
} finally {
sh returnStdout: true, script: """
rm -fr *
"""
try {
sh returnStdout: true, script: """
scp c3po-mme1:${base_log_dir}/* .
"""
} catch (err) {}
archiveArtifacts artifacts: "*${stdout_ext}", allowEmptyArchive: true
archiveArtifacts artifacts: "*${stderr_ext}", allowEmptyArchive: true
}
echo "RESULT: ${currentBuild.result}"
}
}