Commit bee19973 authored by Raphael Defosseux's avatar Raphael Defosseux

CI: Latest version of CI for gNB project

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent adca460e
...@@ -52,35 +52,35 @@ pipeline { ...@@ -52,35 +52,35 @@ pipeline {
stage ("Analysis with cppcheck") { stage ("Analysis with cppcheck") {
steps { steps {
gitlabCommitStatus(name: "Analysis with cppcheck") { gitlabCommitStatus(name: "Analysis with cppcheck") {
sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant cppcheck" sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant cppcheck --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep"
} }
} }
} }
stage ("Build eNb-USRP") { stage ("Build eNb-USRP") {
steps { steps {
gitlabCommitStatus(name: "Build eNb-USRP") { gitlabCommitStatus(name: "Build eNb-USRP") {
sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant enb-usrp" sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant enb-usrp --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep"
} }
} }
} }
stage ("Build 5G gNB-USRP") { stage ("Build 5G gNB-USRP") {
steps { steps {
gitlabCommitStatus(name: "Build gNb-usrp") { gitlabCommitStatus(name: "Build gNb-usrp") {
sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant gnb-usrp" sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant gnb-usrp --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep"
} }
} }
} }
stage ("Build 5G NR-UE-USRP") { stage ("Build 5G NR-UE-USRP") {
steps { steps {
gitlabCommitStatus(name: "Build nr-UE-usrp") { gitlabCommitStatus(name: "Build nr-UE-usrp") {
sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant nu-ue-usrp" sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant nu-ue-usrp --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep"
} }
} }
} }
stage ("Build physical simulators") { stage ("Build physical simulators") {
steps { steps {
gitlabCommitStatus(name: "Build phy-sim") { gitlabCommitStatus(name: "Build phy-sim") {
sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant phy-sim" sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant phy-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep"
} }
} }
} }
...@@ -89,7 +89,7 @@ pipeline { ...@@ -89,7 +89,7 @@ pipeline {
always { always {
script { script {
dir ('archives') { dir ('archives') {
sh "zip -r vm_build_logs.zip enb_usrp phy_sim cppcheck gnb_usrp nrue_usrp" sh "zip -r -qq vm_build_logs.zip enb_usrp phy_sim cppcheck gnb_usrp nrue_usrp"
} }
if(fileExists('archives/vm_build_logs.zip')) { if(fileExists('archives/vm_build_logs.zip')) {
archiveArtifacts artifacts: 'archives/vm_build_logs.zip' archiveArtifacts artifacts: 'archives/vm_build_logs.zip'
...@@ -106,11 +106,18 @@ pipeline { ...@@ -106,11 +106,18 @@ pipeline {
} }
} }
} }
stage ("Destroy all Virtual Machines") {
steps {
sh "./ci-scripts/destroyAllRunningVM.sh --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
}
}
} }
post { post {
always { always {
script { script {
echo "End of script" // Stage destroy may not be run if error in previous stage
sh "./ci-scripts/destroyAllRunningVM.sh --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
} }
} }
success { success {
......
...@@ -15,6 +15,12 @@ function usage { ...@@ -15,6 +15,12 @@ function usage {
echo "" echo ""
echo "Options:" echo "Options:"
echo "--------" echo "--------"
echo " --job-name #### OR -jn ####"
echo " Specify the name of the Jenkins job."
echo ""
echo " --build-id #### OR -id ####"
echo " Specify the build ID of the Jenkins job."
echo ""
echo " --workspace #### OR -ws ####" echo " --workspace #### OR -ws ####"
echo " Specify the workspace." echo " Specify the workspace."
echo "" echo ""
...@@ -47,7 +53,7 @@ function variant_usage { ...@@ -47,7 +53,7 @@ function variant_usage {
echo "" echo ""
} }
if [ $# -lt 1 ] || [ $# -gt 5 ] if [ $# -lt 1 ] || [ $# -gt 9 ]
then then
echo "Syntax Error: not the correct number of arguments" echo "Syntax Error: not the correct number of arguments"
echo "" echo ""
...@@ -55,6 +61,9 @@ then ...@@ -55,6 +61,9 @@ then
exit 1 exit 1
fi fi
VM_TEMPLATE=ci-
JOB_NAME=XX
BUILD_ID=XX
VM_NAME=ci-enb-usrp VM_NAME=ci-enb-usrp
ARCHIVES_LOC=enb_usrp ARCHIVES_LOC=enb_usrp
LOG_PATTERN=.Rel14.txt LOG_PATTERN=.Rel14.txt
...@@ -204,6 +213,14 @@ then ...@@ -204,6 +213,14 @@ then
exit 1 exit 1
fi fi
if [ "$JOB_NAME" == "XX" ] || [ "$BUILD_ID" == "XX" ]
then
VM_TEMPLATE=ci-
else
VM_TEMPLATE=${JOB_NAME}-b${BUILD_ID}-
fi
VM_NAME=`echo $VM_NAME | sed -e "s#ci-#$VM_TEMPLATE#"`
VM_CMDS=${VM_NAME}_cmds.txt VM_CMDS=${VM_NAME}_cmds.txt
ARCHIVES_LOC=${JENKINS_WKSP}/archives/${ARCHIVES_LOC} ARCHIVES_LOC=${JENKINS_WKSP}/archives/${ARCHIVES_LOC}
......
#!/bin/bash
function usage {
echo "OAI VM Destroy script"
echo " Original Author: Raphael Defosseux"
echo ""
echo "Usage:"
echo "------"
echo " destroyAllRunningVM.sh [OPTIONS]"
echo ""
echo "Options:"
echo "--------"
echo " --job-name #### OR -jn ####"
echo " Specify the name of the Jenkins job."
echo ""
echo " --build-id #### OR -id ####"
echo " Specify the build ID of the Jenkins job."
echo ""
echo " --help OR -h"
echo " Print this help message."
echo ""
}
if [ $# -gt 4 ]
then
echo "Syntax Error: not the correct number of arguments"
echo ""
usage
exit 1
fi
VM_TEMPLATE=ci-
JOB_NAME=XX
BUILD_ID=XX
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
shift
usage
exit 0
;;
-jn|--job-name)
JOB_NAME="$2"
shift
shift
;;
-id|--build-id)
BUILD_ID="$2"
shift
shift
;;
*)
echo "Syntax Error: unknown option: $key"
echo ""
usage
exit 1
esac
done
if [ "$JOB_NAME" == "XX" ] || [ "$BUILD_ID" == "XX" ]
then
VM_TEMPLATE=ci-
else
VM_TEMPLATE=${JOB_NAME}-b${BUILD_ID}-
fi
LIST_CI_VM=`uvt-kvm list | grep $VM_TEMPLATE`
for CI_VM in $LIST_CI_VM
do
VM_IP_ADDR=`uvt-kvm ip $CI_VM`
echo "VM to destroy: $CI_VM -- IP $VM_IP_ADDR"
uvt-kvm destroy $CI_VM
ssh-keygen -R $VM_IP_ADDR
done
exit 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment