#!/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 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 "
| Build Start Time (UTC) | " >> ./build_results.html echo "TEMPLATE_BUILD_TIME | " >> ./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 echo "
Please apply the following command to this(ese) file(s):
" >> ./build_results.html echo "astyle --options=ci-scripts/astyle-options.txt filename(s)