scripts: improve automatic jenkins verification [1/1]
PD#SWPL-67525
Problem:
improve automatic jenkins verification
Solution:
improve automatic jenkins verification
Verify:
ad401_a113l
Change-Id: I6fc1d4e5b3e5a46b4ab65fd3352edfe96d75a856
Signed-off-by: Kelvin Zhang <kelvin.zhang@amlogic.com>
diff --git a/build_all.sh b/build_all.sh
index dbc5f29..eaa2f87 100755
--- a/build_all.sh
+++ b/build_all.sh
@@ -49,7 +49,7 @@
[ "$?" -ne 0 ] && echo "Ignore unsupported combination! $LINE" && continue
make distclean
[ "$?" -ne 0 ] && echo "Failed to make distclean! $LINE" && return 2
- echo -n "$nr. Building $LINE ... "
+ echo -n -e "$nr. Building $LINE ...\t"
make >> $BUILD_LOG 2>&1
[ "$?" -ne 0 ] && echo "failed!" && cat $BUILD_LOG && touch $LAST_BUILD_FAILURE && echo -e "\nAborted with errors!\n" && return 3
grep -qr "warning: " $BUILD_LOG
diff --git a/cherry_pick.sh b/cherry_pick.sh
index 4ba623f..e661e9f 100755
--- a/cherry_pick.sh
+++ b/cherry_pick.sh
@@ -22,12 +22,12 @@
if [ "$?" -ne 0 ]; then
git status
git log -1
- echo -e "\nFailed to apply patch!\n"
+ echo -e "\n${FUNCNAME[0]}: Failed to apply patch!\n"
return 1
fi
popd > /dev/null
else
- echo -e "\nNo such directory! $repo_path\n"
+ echo -e "\n${FUNCNAME[0]}: No such directory! $repo_path\n"
return 1
fi
}
@@ -106,12 +106,12 @@
if [ "$?" -ne 0 ]; then
git status
git log -1
- echo -e "-------- Failed to apply patch! --------"
+ echo -e "\n${FUNCNAME[0]}: Failed to apply patch!\n"
exit 1
fi
popd > /dev/null
else
- echo "No such directory! $repo_path"
+ echo -e "\n${FUNCNAME[0]}: No such directory! $repo_path\n"
exit 1
fi
echo -e "-------- Done --------\n"
diff --git a/gerrit_review.sh b/gerrit_review.sh
index b0a6228..ea68d9d 100755
--- a/gerrit_review.sh
+++ b/gerrit_review.sh
@@ -5,23 +5,26 @@
# SPDX-License-Identifier: MIT
#
+# $1: Review result
gerrit_review_for_gerrit_topic() {
+ [ -z "$MANUAL_GERRIT_TOPIC" ] && return
+
[ -z "$OUTPUT_DIR" ] && OUTPUT_DIR=$PWD/output
[ -z "$GERRIT_SERVER" ] && GERRIT_SERVER="scgit.amlogic.com"
[ -z "$GERRIT_PORT" ] && GERRIT_PORT="29418"
[ -z "$GERRIT_QUERY_RESULT" ] && GERRIT_QUERY_RESULT="$OUTPUT_DIR/topic_changes.txt"
- if [ -z "$MANUAL_GERRIT_TOPIC" ] || [ ! -f "$GERRIT_QUERY_RESULT" ]; then
- return
- fi
+ [ ! -f "$GERRIT_QUERY_RESULT" ] && echo "${FUNCNAME[0]}: No such file! $GERRIT_QUERY_RESULT" && exit 1
+ [ $# -ne 1 ] && echo "${FUNCNAME[0]}: Invalid parameters! $*" && exit 1
- if [ "$1" = "SUCCESS" ]; then
- verify_score="+1"
+ if [ "$1" = "Start" ]; then
+ verify_param=""
+ elif [ "$1" = "SUCCESS" ]; then
+ verify_param="--verified +1"
elif [ "$1" = "FAIL" ]; then
- verify_score="-1"
+ verify_param="--verified -1"
else
- echo "gerrit_review_for_gerrit_topic: Invalid parameter $1"
- return
+ echo "${FUNCNAME[0]}: Invalid parameter $1" && exit 1
fi
review_msg="Build ${BUILD_URL}: $1"
@@ -29,19 +32,26 @@
GERRIT_CHANGE_NUMBERS=$(jq -r '.number // empty' $GERRIT_QUERY_RESULT)
GERRIT_PATCHSET_NUMBERS=$(jq -r '.currentPatchSet.number // empty' $GERRIT_QUERY_RESULT)
+ [ "$1" != "Start" ] && echo -e "======== Verifying Gerrit Topic: $MANUAL_GERRIT_TOPIC ========"
i=1
for GERRIT_CHANGE_NUMBER in $GERRIT_CHANGE_NUMBERS; do
GERRIT_PATCHSET_NUMBER=$(echo $GERRIT_PATCHSET_NUMBERS | awk "{print \$$i}")
- echo -n "$GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER $verify_score ... "
- ssh -p $GERRIT_PORT $GERRIT_SERVER gerrit review --verified "${verify_score}" -m "'${review_msg}'" $GERRIT_CHANGE_NUMBER,$GERRIT_PATCHSET_NUMBER
- if [ "$?" -eq 0 ]; then
- echo "OK"
- else
- echo "failed"
+ [ "$1" != "Start" ] && echo -n -e "$GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER $verify_score ...\t"
+ ssh -p $GERRIT_PORT $GERRIT_SERVER gerrit review "${verify_param}" -m "'${review_msg}'" $GERRIT_CHANGE_NUMBER,$GERRIT_PATCHSET_NUMBER
+ if [ "$1" != "Start" ]; then
+ if [ "$?" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "failed"
+ fi
fi
i=$((i+1))
done
+ i=$((i-1))
+ [ "$1" != "Start" ] && [ "$i" -eq 1 ] && echo -e "======== Verified $i Gerrit change for $MANUAL_GERRIT_TOPIC ========\n"
+ [ "$1" != "Start" ] && [ "$i" -gt 1 ] && echo -e "======== Verified $i Gerrit changes for $MANUAL_GERRIT_TOPIC ========\n"
+
if [ "$1" = "FAIL" ]; then
exit 1
fi
diff --git a/jenkins_verify.sh b/jenkins_verify.sh
index 898410d..f800637 100755
--- a/jenkins_verify.sh
+++ b/jenkins_verify.sh
@@ -14,7 +14,7 @@
export XTENSA_SYSTEM=/opt/xtensa/XtDevTools/install/builds/RG-2018.9-linux/Amlogic_v0/config
export XTENSA_CORE=Amlogic_v0
-if [ -z "$MANIFEST_URL" ] || [ -z "$MANIFEST_BRANCH" ] || [ -z "$PROJECT_NAME" ] || [ -z "$BRANCH_NAME" ]; then
+if [ -z "$MANIFEST_BRANCH" ] || [ -z "$PROJECT_NAME" ] || [ -z "$BRANCH_NAME" ]; then
echo "NULL params!"
exit 1
fi
@@ -111,6 +111,7 @@
# Cherry pick patches
source scripts/cherry_pick.sh
[ "$?" -ne 0 ] && gerrit_review_for_gerrit_topic FAIL
+gerrit_review_for_gerrit_topic Start
# Generate Jenkins trigger
[ "$SUBMIT_TYPE" = "daily" ] && source scripts/gen_jenkins_trigger.sh