diff --git a/ci-scripts/buildLocally.sh b/ci-scripts/buildLocally.sh new file mode 100755 index 0000000000..6701950832 --- /dev/null +++ b/ci-scripts/buildLocally.sh @@ -0,0 +1,153 @@ +#!/bin/bash + +function usage { + echo "OAI Local Build Check script" + echo " Original Author: Raphael Defosseux" + echo "" + echo "Usage:" + echo "------" + echo " buildLocally.sh [OPTIONS]" + echo "" + echo "Options:" + echo "--------" + echo " --workspace #### OR -ws ####" + echo " Specify the workspace" + echo "" + echo " --help OR -h" + echo " Print this help message." + echo "" +} + +if [ $# -ne 2 ] && [ $# -ne 1 ] +then + echo "Syntax Error: not the correct number of arguments" + echo "" + usage + exit 1 +fi + +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -h|--help) + shift + usage + exit 0 + ;; + -ws|--workspace) + JENKINS_WKSP="$2" + shift + shift + ;; + *) + echo "Syntax Error: unknown option: $key" + echo "" + usage + exit 1 +esac +done + +cd $JENKINS_WKSP +STATUS=0 + +############################################################ +# Creating a tmp folder to store results and artifacts +############################################################ +if [ ! -d $JENKINS_WKSP/archives ] +then + mkdir $JENKINS_WKSP/archives +fi + +source oaienv +cd $JENKINS_WKSP/cmake_targets + +############################################################ +# Building eNb with USRP option +############################################################ +ARCHIVES_LOC=$JENKINS_WKSP/archives/enb_usrp +if [ ! -d $ARCHIVES_LOC ] +then + mkdir $ARCHIVES_LOC +fi +./build_oai --eNB -w USRP -c + +# Generated log files: +if [ -f $JENKINS_WKSP/cmake_targets/log/lte-softmodem.Rel14.txt ] +then + LOCAL_STAT=`egrep -c "Built target lte-softmodem" $JENKINS_WKSP/cmake_targets/log/lte-softmodem.Rel14.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/lte-softmodem.Rel14.txt $ARCHIVES_LOC +else + STATUS=-1 +fi +if [ -f $JENKINS_WKSP/cmake_targets/log/params_libconfig.Rel14.txt ] +then + LOCAL_STAT=`egrep -c "Built target params_libconfig" $JENKINS_WKSP/cmake_targets/log/params_libconfig.Rel14.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/params_libconfig.Rel14.txt $ARCHIVES_LOC +else + STATUS=-1 +fi +if [ -f $JENKINS_WKSP/cmake_targets/log/coding.Rel14.txt ] +then + LOCAL_STAT=`egrep -c "Built target coding" $JENKINS_WKSP/cmake_targets/log/coding.Rel14.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/coding.Rel14.txt $ARCHIVES_LOC +else + STATUS=-1 +fi +if [ -f $JENKINS_WKSP/cmake_targets/log/oai_usrpdevif.Rel14.txt ] +then + LOCAL_STAT=`egrep -c "Built target oai_usrpdevif" $JENKINS_WKSP/cmake_targets/log/oai_usrpdevif.Rel14.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/oai_usrpdevif.Rel14.txt $ARCHIVES_LOC +else + STATUS=-1 +fi + +############################################################ +# Building basic simulator +############################################################ +ARCHIVES_LOC=$JENKINS_WKSP/archives/basic_sim +if [ ! -d $ARCHIVES_LOC ] +then + mkdir $ARCHIVES_LOC +fi +cd $JENKINS_WKSP/cmake_targets +./build_oai --basic-simulator -c + +# Generated log files: +if [ -f $JENKINS_WKSP/cmake_targets/log/basic_simulator_enb.txt ] +then + LOCAL_STAT=`egrep -c "Built target lte-softmodem" $JENKINS_WKSP/cmake_targets/log/basic_simulator_enb.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/basic_simulator_enb.txt $ARCHIVES_LOC +else + STATUS=-1 +fi +if [ -f $JENKINS_WKSP/cmake_targets/log/basic_simulator_ue.txt ] +then + LOCAL_STAT=`egrep -c "Built target lte-uesoftmodem" $JENKINS_WKSP/cmake_targets/log/basic_simulator_ue.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/basic_simulator_ue.txt $ARCHIVES_LOC +else + STATUS=-1 +fi +if [ -f $JENKINS_WKSP/cmake_targets/log/conf2uedata.Rel14.txt ] +then + LOCAL_STAT=`egrep -c "Built target conf2uedata" $JENKINS_WKSP/cmake_targets/log/conf2uedata.Rel14.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/conf2uedata.Rel14.txt $ARCHIVES_LOC +else + STATUS=-1 +fi + +############################################################ +# Creating a zip for Jenkins archiving +############################################################ +cd $JENKINS_WKSP/archives/ +zip -r local_build_logs.zip basic_sim enb_usrp + +exit $STATUS diff --git a/ci-scripts/buildOnVM.sh b/ci-scripts/buildOnVM.sh new file mode 100755 index 0000000000..ba99436510 --- /dev/null +++ b/ci-scripts/buildOnVM.sh @@ -0,0 +1,370 @@ +#!/bin/bash + +function usage { + echo "OAI VM Build Check script" + echo " Original Author: Raphael Defosseux" + echo " Requirements:" + echo " -- uvtool uvtool-libvirt apt-cacher" + echo " -- xenial image already synced" + echo " Default:" + echo " -- eNB with USRP" + echo "" + echo "Usage:" + echo "------" + echo " buildOnVM.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 " --workspace #### OR -ws ####" + echo " Specify the workspace." + echo "" + echo " --variant enb-usrp OR -v1" + echo " --variant basic-sim OR -v2" + echo " --variant phy-sim OR -v3" + echo " --variant cppcheck OR -v4" + echo " --variant enb-ethernet OR -v7" + echo " --variant ue-ethernet OR -v8" + echo " Specify the variant to build." + echo "" + echo " --keep-vm-alive OR -k" + echo " Keep the VM alive after the build." + echo "" + echo " --help OR -h" + echo " Print this help message." + echo "" +} + +function variant_usage { + echo "OAI VM Build Check script" + echo " Original Author: Raphael Defosseux" + echo "" + echo " --variant enb-usrp OR -v1" + echo " --variant basic-sim OR -v2" + echo " --variant phy-sim OR -v3" + echo " --variant cppcheck OR -v4" + echo " --variant enb-ethernet OR -v7" + echo " --variant ue-ethernet OR -v8" + echo "" +} + +if [ $# -lt 1 ] || [ $# -gt 9 ] +then + echo "Syntax Error: not the correct number of arguments" + echo "" + usage + exit 1 +fi + +VM_TEMPLATE=ci- +JOB_NAME=XX +BUILD_ID=XX +VM_NAME=ci-enb-usrp +ARCHIVES_LOC=enb_usrp +LOG_PATTERN=.Rel14.txt +NB_PATTERN_FILES=4 +BUILD_OPTIONS="--eNB -w USRP" +KEEP_VM_ALIVE=0 + +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 + ;; + -ws|--workspace) + JENKINS_WKSP="$2" + shift + shift + ;; + -k|--keep-vm-alive) + KEEP_VM_ALIVE=1 + shift + ;; + -v1) + VM_NAME=ci-enb-usrp + ARCHIVES_LOC=enb_usrp + LOG_PATTERN=.Rel14.txt + NB_PATTERN_FILES=4 + BUILD_OPTIONS="--eNB -w USRP" + shift + ;; + -v2) + VM_NAME=ci-basic-sim + ARCHIVES_LOC=basic_sim + LOG_PATTERN=basic_simulator + NB_PATTERN_FILES=2 + BUILD_OPTIONS="--basic-simulator" + shift + ;; + -v3) + VM_NAME=ci-phy-sim + ARCHIVES_LOC=phy_sim + LOG_PATTERN=.Rel14.txt + NB_PATTERN_FILES=3 + BUILD_OPTIONS="--phy_simulators" + shift + ;; + -v4) + VM_NAME=ci-cppcheck + ARCHIVES_LOC=cppcheck + LOG_PATTERN=cppcheck.xml + NB_PATTERN_FILES=1 + BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2" + shift + ;; + -v7) + VM_NAME=ci-enb-ethernet + ARCHIVES_LOC=enb_eth + LOG_PATTERN=.Rel14.txt + NB_PATTERN_FILES=6 + BUILD_OPTIONS="--eNB -t ETHERNET --noS1" + shift + ;; + -v8) + VM_NAME=ci-ue-ethernet + ARCHIVES_LOC=ue_eth + LOG_PATTERN=.Rel14.txt + NB_PATTERN_FILES=6 + BUILD_OPTIONS="--UE -t ETHERNET --noS1" + shift + ;; + --variant) + variant="$2" + case $variant in + enb-usrp) + VM_NAME=ci-enb-usrp + ARCHIVES_LOC=enb_usrp + LOG_PATTERN=.Rel14.txt + NB_PATTERN_FILES=4 + BUILD_OPTIONS="--eNB -w USRP" + ;; + basic-sim) + VM_NAME=ci-basic-sim + ARCHIVES_LOC=basic_sim + LOG_PATTERN=basic_simulator + NB_PATTERN_FILES=2 + BUILD_OPTIONS="--basic-simulator" + ;; + phy-sim) + VM_NAME=ci-phy-sim + ARCHIVES_LOC=phy_sim + LOG_PATTERN=.Rel14.txt + NB_PATTERN_FILES=3 + BUILD_OPTIONS="--phy_simulators" + ;; + cppcheck) + VM_NAME=ci-cppcheck + ARCHIVES_LOC=cppcheck + LOG_PATTERN=cppcheck.xml + NB_PATTERN_FILES=1 + BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2" + ;; + enb-ethernet) + VM_NAME=ci-enb-ethernet + ARCHIVES_LOC=enb_eth + LOG_PATTERN=.Rel14.txt + NB_PATTERN_FILES=6 + BUILD_OPTIONS="--eNB -t ETHERNET --noS1" + ;; + ue-ethernet) + VM_NAME=ci-ue-ethernet + ARCHIVES_LOC=ue_eth + LOG_PATTERN=.Rel14.txt + NB_PATTERN_FILES=6 + BUILD_OPTIONS="--UE -t ETHERNET --noS1" + ;; + *) + echo "" + echo "Syntax Error: Invalid Variant option -> $variant" + echo "" + variant_usage + exit 1 + esac + shift + shift + ;; + *) + echo "Syntax Error: unknown option: $key" + echo "" + usage + exit 1 +esac +done + +if [ ! -f $JENKINS_WKSP/localZip.zip ] +then + echo "Missing localZip.zip file!" + exit 1 +fi +if [ ! -f /etc/apt/apt.conf.d/01proxy ] +then + echo "Missing /etc/apt/apt.conf.d/01proxy file!" + echo "Is apt-cacher installed and configured?" + exit 1 +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 +ARCHIVES_LOC=${JENKINS_WKSP}/archives/${ARCHIVES_LOC} + +echo "VM_NAME = $VM_NAME" +echo "VM_CMD_FILE = $VM_CMDS" +echo "JENKINS_WKSP = $JENKINS_WKSP" +echo "ARCHIVES_LOC = $ARCHIVES_LOC" +echo "BUILD_OPTIONS = $BUILD_OPTIONS" + +IS_VM_ALIVE=`uvt-kvm list | grep -c $VM_NAME` + +if [ $IS_VM_ALIVE -eq 0 ] +then + echo "############################################################" + echo "Creating VM ($VM_NAME) on Ubuntu Cloud Image base" + echo "############################################################" + uvt-kvm create $VM_NAME release=xenial --memory 2048 --cpu 4 --unsafe-caching --template ci-scripts/template-host.xml +fi + +echo "Waiting for VM to be started" +uvt-kvm wait $VM_NAME --insecure + +VM_IP_ADDR=`uvt-kvm ip $VM_NAME` +echo "$VM_NAME has for IP addr = $VM_IP_ADDR" + +echo "############################################################" +echo "Copying GIT repo into VM ($VM_NAME)" +echo "############################################################" +scp -o StrictHostKeyChecking=no localZip.zip ubuntu@$VM_IP_ADDR:/home/ubuntu +scp -o StrictHostKeyChecking=no /etc/apt/apt.conf.d/01proxy ubuntu@$VM_IP_ADDR:/home/ubuntu + +echo "############################################################" +echo "Running install and build script on VM ($VM_NAME)" +echo "############################################################" +echo "sudo cp 01proxy /etc/apt/apt.conf.d/" > $VM_CMDS +if [[ "$VM_NAME" == *"-cppcheck"* ]] +then + echo "echo \"sudo apt-get --yes --quiet install zip cppcheck \"" >> $VM_CMDS + echo "sudo apt-get update > zip-install.txt 2>&1" >> $VM_CMDS + echo "sudo apt-get --yes install zip cppcheck >> zip-install.txt 2>&1" >> $VM_CMDS +else + echo "echo \"sudo apt-get --yes --quiet install zip subversion libboost-dev \"" >> $VM_CMDS + echo "sudo apt-get update > zip-install.txt 2>&1" >> $VM_CMDS + echo "sudo apt-get --yes install zip subversion libboost-dev >> zip-install.txt 2>&1" >> $VM_CMDS +fi +echo "mkdir tmp" >> $VM_CMDS +echo "cd tmp" >> $VM_CMDS +echo "echo \"unzip -qq -DD ../localZip.zip\"" >> $VM_CMDS +echo "unzip -qq -DD ../localZip.zip" >> $VM_CMDS +if [[ "$VM_NAME" == *"-cppcheck"* ]] +then + echo "mkdir cmake_targets/log" >> $VM_CMDS + echo "cp /home/ubuntu/zip-install.txt cmake_targets/log" >> $VM_CMDS + echo "echo \"cppcheck $BUILD_OPTIONS . \"" >> $VM_CMDS + echo "cppcheck $BUILD_OPTIONS . 2> cmake_targets/log/cppcheck.xml 1> cmake_targets/log/cppcheck_build.txt" >> $VM_CMDS +else + echo "echo \"source oaienv\"" >> $VM_CMDS + echo "source oaienv" >> $VM_CMDS + echo "cd cmake_targets/" >> $VM_CMDS + echo "mkdir log" >> $VM_CMDS + echo "cp /home/ubuntu/zip-install.txt log" >> $VM_CMDS + echo "echo \"./build_oai -I $BUILD_OPTIONS \"" >> $VM_CMDS + echo "./build_oai -I $BUILD_OPTIONS > log/install-build.txt 2>&1" >> $VM_CMDS +fi +ssh -o StrictHostKeyChecking=no ubuntu@$VM_IP_ADDR < $VM_CMDS + +echo "############################################################" +echo "Creating a tmp folder to store results and artifacts" +echo "############################################################" +if [ ! -d $JENKINS_WKSP/archives ] +then + mkdir $JENKINS_WKSP/archives +fi + +if [ ! -d $ARCHIVES_LOC ] +then + mkdir $ARCHIVES_LOC +fi + +scp -o StrictHostKeyChecking=no ubuntu@$VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/*.txt $ARCHIVES_LOC +if [[ "$VM_NAME" == *"-cppcheck"* ]] +then + scp -o StrictHostKeyChecking=no ubuntu@$VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/*.xml $ARCHIVES_LOC +fi + +if [ $KEEP_VM_ALIVE -eq 0 ] +then + echo "############################################################" + echo "Destroying VM" + echo "############################################################" + uvt-kvm destroy $VM_NAME + ssh-keygen -R $VM_IP_ADDR +fi +rm -f $VM_CMDS + +echo "############################################################" +echo "Checking build status" +echo "############################################################" + +LOG_FILES=`ls $ARCHIVES_LOC/*.txt $ARCHIVES_LOC/*.xml` +STATUS=0 +NB_FOUND_FILES=0 + +for FULLFILE in $LOG_FILES +do + if [[ $FULLFILE == *"$LOG_PATTERN"* ]] + then + filename=$(basename -- "$FULLFILE") + if [ "$LOG_PATTERN" == ".Rel14.txt" ] + then + PASS_PATTERN=`echo $filename | sed -e "s#$LOG_PATTERN##"` + fi + if [ "$LOG_PATTERN" == "basic_simulator" ] + then + PASS_PATTERN="lte-" + fi + if [ "$LOG_PATTERN" == "cppcheck.xml" ] + then + PASS_PATTERN="results version" + LOCAL_STAT=`egrep -c "$PASS_PATTERN" $FULLFILE` + else + LOCAL_STAT=`egrep -c "Built target $PASS_PATTERN" $FULLFILE` + fi + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + NB_FOUND_FILES=$((NB_FOUND_FILES + 1)) + fi +done + +if [ $NB_PATTERN_FILES -ne $NB_FOUND_FILES ]; then STATUS=-1; fi + +if [ $STATUS -eq 0 ] +then + echo "STATUS seems OK" +else + echo "STATUS failed?" +fi +exit $STATUS diff --git a/ci-scripts/createVM.sh b/ci-scripts/createVM.sh new file mode 100755 index 0000000000..02d9523d67 --- /dev/null +++ b/ci-scripts/createVM.sh @@ -0,0 +1,167 @@ +#!/bin/bash + +function usage { + echo "OAI VM Creation script" + echo " Original Author: Raphael Defosseux" + echo " Requirements:" + echo " -- uvtool uvtool-libvirt apt-cacher" + echo " -- xenial image already synced" + echo " Default:" + echo " -- eNB with USRP" + echo "" + echo "Usage:" + echo "------" + echo " createVM.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 " --variant enb-usrp OR -v1" + echo " --variant basic-sim OR -v2" + echo " --variant phy-sim OR -v3" + echo " --variant cppcheck OR -v4" + echo " --variant enb-ethernet OR -v7" + echo " --variant ue-ethernet OR -v8" + echo " Specify the variant to build." + echo "" + echo " --help OR -h" + echo " Print this help message." + echo "" +} + +function variant_usage { + echo "OAI VM Build Check script" + echo " Original Author: Raphael Defosseux" + echo "" + echo " --variant enb-usrp OR -v1" + echo " --variant basic-sim OR -v2" + echo " --variant phy-sim OR -v3" + echo " --variant cppcheck OR -v4" + echo " --variant enb-ethernet OR -v7" + echo " --variant ue-ethernet OR -v8" + echo "" +} + +if [ $# -lt 1 ] || [ $# -gt 6 ] +then + echo "Syntax Error: not the correct number of arguments" + echo "" + usage + exit 1 +fi + +VM_TEMPLATE=ci- +JOB_NAME=XX +BUILD_ID=XX +VM_NAME=ci-enb-usrp + +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 + ;; + -v1) + VM_NAME=ci-enb-usrp + shift + ;; + -v2) + VM_NAME=ci-basic-sim + shift + ;; + -v3) + VM_NAME=ci-phy-sim + shift + ;; + -v4) + VM_NAME=ci-cppcheck + shift + ;; + -v7) + VM_NAME=ci-enb-ethernet + shift + ;; + -v8) + VM_NAME=ci-ue-ethernet + shift + ;; + --variant) + variant="$2" + case $variant in + enb-usrp) + VM_NAME=ci-enb-usrp + ;; + basic-sim) + VM_NAME=ci-basic-sim + ;; + phy-sim) + VM_NAME=ci-phy-sim + ;; + cppcheck) + VM_NAME=ci-cppcheck + ;; + enb-ethernet) + VM_NAME=ci-enb-ethernet + ;; + ue-ethernet) + VM_NAME=ci-ue-ethernet + ;; + *) + echo "" + echo "Syntax Error: Invalid Variant option -> $variant" + echo "" + variant_usage + exit 1 + esac + 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 + +VM_NAME=`echo $VM_NAME | sed -e "s#ci-#$VM_TEMPLATE#"` +VM_CMDS=${VM_NAME}_cmds.txt + +echo "VM_NAME = $VM_NAME" + +echo "############################################################" +echo "Creating VM ($VM_NAME) on Ubuntu Cloud Image base" +echo "############################################################" +uvt-kvm create $VM_NAME release=xenial --memory 2048 --cpu 4 --unsafe-caching --template ci-scripts/template-host.xml +echo "Waiting for VM to be started" +uvt-kvm wait $VM_NAME --insecure + +VM_IP_ADDR=`uvt-kvm ip $VM_NAME` +echo "$VM_NAME has for IP addr = $VM_IP_ADDR" +exit 0 diff --git a/ci-scripts/destroyAllRunningVM.sh b/ci-scripts/destroyAllRunningVM.sh new file mode 100755 index 0000000000..c9eb43b4ef --- /dev/null +++ b/ci-scripts/destroyAllRunningVM.sh @@ -0,0 +1,81 @@ +#!/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 + diff --git a/ci-scripts/reportBuildLocally.sh b/ci-scripts/reportBuildLocally.sh new file mode 100755 index 0000000000..694e92e478 --- /dev/null +++ b/ci-scripts/reportBuildLocally.sh @@ -0,0 +1,557 @@ +#!/bin/bash + +function usage { + echo "OAI Local Build Report script" + echo " Original Author: Raphael Defosseux" + echo "" + echo "Usage:" + echo "------" + echo "" + echo " reportBuildLocally.sh [OPTIONS]" + echo "" + echo "Options:" + echo "--------" + echo "" + echo " --help OR -h" + echo " Print this help message." + echo "" + echo "Job Options:" + echo "------------" + echo "" + echo " --git-url #### OR -gu ####" + echo " Specify the URL of the GIT Repository." + 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 " --trigger merge-request OR -mr" + echo " --trigger push OR -pu" + echo " Specify trigger action of the Jenkins job. Either a merge-request event or a push event." + echo "" + echo "Merge-Request Options:" + echo "----------------------" + echo "" + echo " --src-branch #### OR -sb ####" + echo " Specify the source branch of the merge request." + echo "" + echo " --src-commit #### OR -sc ####" + echo " Specify the source commit ID (SHA-1) of the merge request." + echo "" + echo " --target-branch #### OR -tb ####" + echo " Specify the target branch of the merge request (usually develop)." + echo "" + echo " --target-commit #### OR -tc ####" + echo " Specify the target commit ID (SHA-1) of the merge request." + echo "" + echo "Push Options:" + echo "----------------------" + echo "" + echo " --branch #### OR -br ####" + echo " Specify the branch of the push event." + echo "" + echo " --commit #### OR -co ####" + echo " Specify the commit ID (SHA-1) of the push event." + echo "" + echo "" +} + +function trigger_usage { + echo "OAI Local Build Report script" + echo " Original Author: Raphael Defosseux" + echo "" + echo " --trigger merge-request OR -mr" + echo " --trigger push OR -pu" + echo " Specify trigger action of the Jenkins job. Either a merge-request event or a push event." + echo "" +} + +function details_table { + echo "
| File | " >> $3 + echo "Line Number | " >> $3 + echo "Status | " >> $3 + echo "Message | " >> $3 + echo "$COMPLETE_MESSAGE | " >> $3 + echo " " >> $3 + fi + echo "
|---|---|---|---|
| $FILENAME | " >> $3 + echo "$LINENB | " >> $3 + else + if [[ $MESSAGE == *"warning:"* ]] || [[ $MESSAGE == *"error:"* ]] + then + MSGTYPE=`echo $MESSAGE | sed -e "s#:##g"` + echo "$MSGTYPE | " >> $3 + COMPLETE_MESSAGE="" + else + COMPLETE_MESSAGE=$COMPLETE_MESSAGE" "$MESSAGE + fi + fi + done + + if [ "$COMPLETE_MESSAGE" != "start" ] + then + COMPLETE_MESSAGE=`echo $COMPLETE_MESSAGE | sed -e "s#‘#'#g" -e "s#’#'#g"` + echo "$COMPLETE_MESSAGE | " >> $3 + echo "
| Element | " >> ./build_results.html + echo "Status | " >> ./build_results.html + echo "Nb Errors | " >> ./build_results.html + echo "Nb Warnings | " >> ./build_results.html + echo "|||||||
|---|---|---|---|---|---|---|---|---|---|---|
| $1" >> ./build_results.html + if [ -f $2 ] + then + STATUS=`egrep -c "$3" $2` + if [ $STATUS -eq 1 ] + then + echo " | OK" >> ./build_results.html + else + echo " | KO" >> ./build_results.html + fi + NB_ERRORS=`egrep -c "error:" $2` + if [ $NB_ERRORS -eq 0 ] + then + echo " | $NB_ERRORS" >> ./build_results.html + else + echo " | $NB_ERRORS" >> ./build_results.html + fi + NB_WARNINGS=`egrep "warning:" $2 | egrep -v "jobserver unavailable|Clock skew detected.|flexran.proto" | egrep -c "warning:"` + if [ $NB_WARNINGS -eq 0 ] + then + echo " | $NB_WARNINGS" >> ./build_results.html + else + if [ $NB_WARNINGS -gt 20 ] + then + echo " | $NB_WARNINGS" >> ./build_results.html + else + echo " | $NB_WARNINGS" >> ./build_results.html + fi + fi + if [ $NB_ERRORS -ne 0 ] || [ $NB_WARNINGS -ne 0 ] + then + details_table "$1" $2 $4 + fi + else + echo " | Unknown" >> ./build_results.html + echo " | --" >> ./build_results.html + echo " | --" >> ./build_results.html + fi + echo " |
| Error / Warning Type | " >> ./build_results.html + echo "Nb Errors | " >> ./build_results.html + echo "Nb Warnings | " >> ./build_results.html + echo "||
|---|---|---|---|---|
| $2 | " >> ./build_results.html + if [ -f $1 ] + then + NB_ERRORS=`egrep "severity=\"error\"" $1 | egrep -c "id=\"$3\""` + echo "$NB_ERRORS | " >> ./build_results.html + echo "N/A | " >> ./build_results.html + if [ -f ccp_error_cnt.txt ] + then + TOTAL_ERRORS=`cat ccp_error_cnt.txt` + TOTAL_ERRORS=$((TOTAL_ERRORS + NB_ERRORS)) + echo $TOTAL_ERRORS > ccp_error_cnt.txt + fi + else + echo "Unknown | " >> ./build_results.html + echo "Unknown | " >> ./build_results.html + fi + echo "
| Others | " >> ./build_results.html + TOTAL_ERRORS=`cat ccp_error_cnt.txt` + TOTAL_ERRORS=$((NB_ERRORS - TOTAL_ERRORS)) + echo "$TOTAL_ERRORS | " >> ./build_results.html + echo "$NB_WARNINGS | " >> ./build_results.html + echo "||
| Total | " >> ./build_results.html + echo "$NB_ERRORS | " >> ./build_results.html + echo "$NB_WARNINGS | " >> ./build_results.html + else + echo "||
| Total | " >> ./build_results.html + echo "Unknown | " >> ./build_results.html + echo "Unknown | " >> ./build_results.html + if [ -f ccp_error_cnt.txt ] + then + rm -f ccp_error_cnt.txt + fi + fi + echo "
Full details in zipped artifact (cppcheck/cppcheck.xml)
" >> ./build_results.html + echo "Graphical Interface tool : cppcheck-gui -l cppcheck/cppcheck.xml
" >> ./build_results.html
+echo " " >> ./build_results.html
+echo " " >> ./build_results.html
+echo " " >> ./build_results.html
+echo " " >> ./build_results.html
+echo " | " >> ./build_results.html
+echo " " >> ./build_results.html +echo " Job Summary -- Job: $JOB_NAME -- Build-ID: $BUILD_ID" >> ./build_results.html +echo " | " >> ./build_results.html +echo "
| GIT Repository | " >> ./build_results.html +echo "$GIT_URL | " >> ./build_results.html +echo "|
| Job Trigger | " >> ./build_results.html +if [ $PU_TRIG -eq 1 ]; then echo "Push Event | " >> ./build_results.html; fi +if [ $MR_TRIG -eq 1 ]; then echo "Merge-Request | " >> ./build_results.html; fi +echo "
| Branch | " >> ./build_results.html + echo "$SOURCE_BRANCH | " >> ./build_results.html + echo "|
| Commit ID | " >> ./build_results.html + echo "$SOURCE_COMMIT_ID | " >> ./build_results.html + echo "|
| Source Branch | " >> ./build_results.html + echo "$SOURCE_BRANCH | " >> ./build_results.html + echo "|
| Source Commit ID | " >> ./build_results.html + echo "$SOURCE_COMMIT_ID | " >> ./build_results.html + echo "|
| Target Branch | " >> ./build_results.html + echo "$TARGET_BRANCH | " >> ./build_results.html + echo "|
| Target Commit ID | " >> ./build_results.html + echo "$TARGET_COMMIT_ID | " >> ./build_results.html + echo "
| Result: | " >> ./build_results.html + NB_FILES=`cat ./oai_rules_result.txt` + if [ $NB_FILES = "0" ] + then + if [ $PU_TRIG -eq 1 ]; then echo "All files in repository follow OAI rules. | " >> ./build_results.html; fi + if [ $MR_TRIG -eq 1 ]; then echo "All modified files in Merge-Request follow OAI rules. | " >> ./build_results.html; fi + else + if [ $PU_TRIG -eq 1 ]; then echo "$NB_FILES files in repository DO NOT follow OAI rules. | " >> ./build_results.html; fi + if [ $MR_TRIG -eq 1 ]; then echo "$NB_FILES modified files in Merge-Request DO NOT follow OAI rules. | " >> ./build_results.html; fi + fi + echo "
| Hostname | +Nb Tests | +Failures | +Timestamp | +
|---|---|---|---|
|
+ |
+
+ |
+
+ |
+
+ |
+
| Test Name | +Result | +Time | +Description | +
|---|---|---|---|
|
+ |
+
+ |
+
+ |
+
+ |
+