1- pipeline {
1+ pipeline {
22
33 agent {
4- label " jenkins-client-for-cortx-motr "
4+ label " code-coverage "
55 }
66
77 parameters {
8- string(name : ' NODE_HOST' , defaultValue : ' ' , description : ' Node 1 Host FQDN' , trim : true )
9- string(name : ' NODE_USER' , defaultValue : ' ' , description : ' Host machine root user' , trim : true )
10- string(name : ' NODE_PASS' , defaultValue : ' ' , description : ' Host machine root user password' , trim : true )
118 string(name : ' BRANCH' , defaultValue : ' ' , description : ' Branch name' , trim : true )
129 string(name : ' OPTIONS' , defaultValue : ' ' , description : ' Build options' , trim : true )
1310 booleanParam(name : ' UT' , defaultValue : true , description : ' Run UT' )
@@ -17,58 +14,72 @@ pipeline {
1714 options {
1815 timeout(time : 180 , unit : ' MINUTES' )
1916 timestamps()
20- ansiColor(' xterm' )
17+ ansiColor(' xterm' )
2118 buildDiscarder(logRotator(numToKeepStr : " 30" ))
2219 }
2320
2421 environment {
25- NODE_PASS = " ${ NODE_PASS.isEmpty() ? NODE_DEFAULT_SSH_CRED_PSW : NODE_PASS } "
22+ TestList = " /tmp/list-of-unit-tests.txt "
2623 }
2724
2825 stages {
29- stage(' Checkout' ) {
30- steps {
31- checkout([$class : ' GitSCM' , branches : [[name : " main" ]], doGenerateSubmoduleConfigurations : false , extensions : [[$class : ' PathRestriction' , excludedRegions : ' ' , includedRegions : ' scripts/third-party-rpm/.*' ]], submoduleCfg : [], userRemoteConfigs : [[credentialsId : ' cortx-admin-github' , url : " https://github.com/Seagate/cortx-motr" ]]])
32- }
33- }
3426 stage (' Compile, execute test and report code coverage' ) {
3527 steps {
3628 script { build_stage = env. STAGE_NAME }
37- sh label : ' Clean up and build motr and run ut for code coverage' , script : '''
38- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} hostname
39- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "yum install -y httpd lcov"
40- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "systemctl start httpd.service"
41- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "rm -rf /root/cortx-motr"
29+ sh label : ' Clean up, build motr, run ut/st and generate code coverage report' , script : '''
30+ hostname
31+ pwd
32+ yum install -y httpd lcov
33+ systemctl start httpd.service
34+ make uninstall || true
35+ make clean || true
36+ rm -rf cortx-motr
4237 OLD_BUILD_NUMBER=$(echo "$BUILD_NUMBER - 10" | bc)
4338 echo "Old build number is : $OLD_BUILD_NUMBER"
44- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "rm -rf /var/www/html/$OLD_BUILD_NUMBER || true"
45- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/ ; git clone --recursive -b ${BRANCH} https://github.com/Seagate/cortx-motr"
46- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; sudo ./scripts/install-build-deps"
47- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; ./autogen.sh"
48- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; ./configure --enable-coverage --enable-debug ${OPTIONS}"
49- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; make -j6"
39+ rm -rf /var/www/html/$OLD_BUILD_NUMBER || true
40+ git clone --recursive -b ${BRANCH} https://github.com/Seagate/cortx-motr cortx-motr
41+ cd cortx-motr
42+ sudo ./scripts/install-build-deps
43+ ./autogen.sh
44+ ./configure --enable-coverage --enable-debug ${OPTIONS}
45+ make -j6
5046
5147 if [ ${UT} == true ]
5248 then
53- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; sudo ./scripts/m0 run-ut"
49+ ./scripts/m0 run-ut -l > "$TestList"
50+ set +o errexit
51+ while read Test
52+ do
53+ echo "Executing: $Test"
54+ timeout --preserve-status -k 600s 600s ./scripts/m0 run-ut -t $Test
55+ echo "Test $Test Executed and exited with return code $?"
56+ done < "$TestList"
5457 fi
5558
5659 if [ ${ST} == true ]
5760 then
58- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; sudo ./scripts/m0 run-st"
61+ ./scripts/m0 run-ut -l > "$TestList"
62+ set +o errexit
63+ while read Test
64+ do
65+ echo "Executing: $Test"
66+ timeout --preserve-status -k 600s 600s ./scripts/m0 run-st -t $Test
67+ echo "Test $Test Executed and exited with return code $?"
68+ done < "$TestList"
5969 fi
6070
61- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; ./scripts/coverage/gcov-gen-html user ./ ./"
62- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} " mkdir -p /var/www/html/$BUILD_NUMBER"
63- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} " cp -r /root/cortx-motr/ * /var/www/html/$BUILD_NUMBER/"
64- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} " systemctl start firewalld.service"
65- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} " firewall-cmd --permanent --add-port=80/tcp"
66- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} " firewall-cmd --permanent --add-port=443/tcp"
67- sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} " firewall-cmd --reload"
68- echo "http://${NODE_HOST} /${BUILD_NUMBER}/"
71+ ./scripts/coverage/gcov-gen-html user ./ ./
72+ mkdir -p /var/www/html/$BUILD_NUMBER
73+ cp -r * /var/www/html/$BUILD_NUMBER/
74+ systemctl start firewalld.service
75+ firewall-cmd --permanent --add-port=80/tcp
76+ firewall-cmd --permanent --add-port=443/tcp
77+ firewall-cmd --reload
78+ echo "http://$(hostname) /${BUILD_NUMBER}/"
6979
7080 '''
7181 }
7282 }
7383 }
7484}
85+
0 commit comments