Commit 348d9aaa authored by Raphael Defosseux's avatar Raphael Defosseux

CI: enhancements

  -- VM are kept alive to prepare for running tests
  -- Added destroy script to kill all VM after run
  -- VM names are now based on jobname and buildid
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 76ff6586
...@@ -52,28 +52,28 @@ pipeline { ...@@ -52,28 +52,28 @@ 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 basic simulator") { stage ("Build basic simulator") {
steps { steps {
gitlabCommitStatus(name: "Build basic-sim") { gitlabCommitStatus(name: "Build basic-sim") {
sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant basic-sim" sh "./ci-scripts/buildOnVM.sh --workspace $WORKSPACE --variant basic-sim --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"
} }
} }
} }
...@@ -99,11 +99,18 @@ pipeline { ...@@ -99,11 +99,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 ""
...@@ -43,7 +49,7 @@ function variant_usage { ...@@ -43,7 +49,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 ""
...@@ -51,6 +57,9 @@ then ...@@ -51,6 +57,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
...@@ -68,6 +77,16 @@ case $key in ...@@ -68,6 +77,16 @@ case $key in
usage usage
exit 0 exit 0
;; ;;
-jn|--job-name)
JOB_NAME="$2"
shift
shift
;;
-id|--build-id)
BUILD_ID="$2"
shift
shift
;;
-ws|--workspace) -ws|--workspace)
JENKINS_WKSP="$2" JENKINS_WKSP="$2"
shift shift
...@@ -170,6 +189,14 @@ then ...@@ -170,6 +189,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