#!/bin/bash
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
# *
# * 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.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
function report_build_usage {
echo "OAI CI VM script"
echo " Original Author: Raphael Defosseux"
echo ""
echo "Usage:"
echo "------"
echo " oai-ci-vm-tool report-build [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 " --workspace #### OR -ws ####"
echo " Specify the workspace."
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 CI VM 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 "
$1
" >> $3
echo "
" >> $3
echo "
" >> $3
echo "
File
" >> $3
echo "
Line Number
" >> $3
echo "
Status
" >> $3
echo "
Message
" >> $3
echo "
" >> $3
LIST_MESSAGES=`egrep "error:|warning:" $2 | egrep -v "jobserver unavailable|Clock skew detected.|flexran.proto"`
COMPLETE_MESSAGE="start"
for MESSAGE in $LIST_MESSAGES
do
if [[ $MESSAGE == *"/home/ubuntu/tmp"* ]] || [[ $MESSAGE == *"/tmp/CI-eNB"* ]]
then
FILENAME=`echo $MESSAGE | sed -e "s#^/home/ubuntu/tmp/##" -e "s#^.*/tmp/CI-eNB/##" | awk -F ":" '{print $1}'`
LINENB=`echo $MESSAGE | awk -F ":" '{print $2}'`
if [ "$COMPLETE_MESSAGE" != "start" ]
then
COMPLETE_MESSAGE=`echo $COMPLETE_MESSAGE | sed -e "s#‘#'#g" -e "s#’#'#g"`
echo "
$COMPLETE_MESSAGE
" >> $3
echo " " >> $3
fi
echo "
" >> $3
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 "
" >> $3
fi
echo "
" >> $3
}
function summary_table_header {
echo "
$1
" >> ./build_results.html
if [ -f $2/build_final_status.log ]
then
if [ `grep -c BUILD_OK $2/build_final_status.log` -eq 1 ]
then
echo "
" >> ./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 "
" >> ./build_results.html
if [ $PU_TRIG -eq 1 ]
then
echo "
" >> ./build_results.html
echo "
Branch
" >> ./build_results.html
echo "
$SOURCE_BRANCH
" >> ./build_results.html
echo "
" >> ./build_results.html
echo "
" >> ./build_results.html
echo "
Commit ID
" >> ./build_results.html
echo "
$SOURCE_COMMIT_ID
" >> ./build_results.html
echo "
" >> ./build_results.html
fi
if [ $MR_TRIG -eq 1 ]
then
echo "
" >> ./build_results.html
echo "
Source Branch
" >> ./build_results.html
echo "
$SOURCE_BRANCH
" >> ./build_results.html
echo "
" >> ./build_results.html
echo "
" >> ./build_results.html
echo "
Source Commit ID
" >> ./build_results.html
echo "
$SOURCE_COMMIT_ID
" >> ./build_results.html
echo "
" >> ./build_results.html
echo "
" >> ./build_results.html
echo "
Target Branch
" >> ./build_results.html
echo "
$TARGET_BRANCH
" >> ./build_results.html
echo "
" >> ./build_results.html
echo "
" >> ./build_results.html
echo "
Target Commit ID
" >> ./build_results.html
echo "
$TARGET_COMMIT_ID
" >> ./build_results.html
echo "
" >> ./build_results.html
fi
echo "
" >> ./build_results.html
echo "
Build Summary
" >> ./build_results.html
if [ -f ./oai_rules_result.txt ]
then
echo "
OAI Coding / Formatting Guidelines Check
" >> ./build_results.html
NB_FILES=`cat ./oai_rules_result.txt`
if [ $NB_FILES = "0" ]
then
echo "
" >> ./build_results.html
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
echo "
" >> ./build_results.html
else
echo "
" >> ./build_results.html
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
echo "
" >> ./build_results.html
fi
if [ -f ./oai_rules_result_list.txt ]
then
echo " " >> ./build_results.html
echo "
" >> ./build_results.html
echo "
Please apply the following command to this(ese) file(s):
" >> ./build_results.html
for DETAILS_TABLE in `ls ./enb_usrp_row*.html`
do
cat $DETAILS_TABLE >> ./build_results.html
done
for DETAILS_TABLE in `ls ./basic_sim_row*.html`
do
cat $DETAILS_TABLE >> ./build_results.html
done
for DETAILS_TABLE in `ls ./phy_sim_row*.html`
do
cat $DETAILS_TABLE >> ./build_results.html
done
for DETAILS_TABLE in `ls ./gnb_usrp_row*.html`
do
cat $DETAILS_TABLE >> ./build_results.html
done
for DETAILS_TABLE in `ls ./nrue_usrp_row*.html`
do
cat $DETAILS_TABLE >> ./build_results.html
done
for DETAILS_TABLE in `ls ./enb_eth_row*.html`
do
cat $DETAILS_TABLE >> ./build_results.html
done
for DETAILS_TABLE in `ls ./ue_eth_row*.html`
do
cat $DETAILS_TABLE >> ./build_results.html
done
if [ -e ./archives/red_hat ]
then
for DETAILS_TABLE in `ls ./enb_usrp_rh_row*.html`
do
cat $DETAILS_TABLE >> ./build_results.html
done
fi
rm -f ./*_row*.html
echo "