SPEC-2703: do not fail with set -xe 89/22389/4
authorCorentin LABBE <clabbe@baylibre.com>
Wed, 11 Sep 2019 18:49:34 +0000 (20:49 +0200)
committerCorentin LABBE <clabbe@baylibre.com>
Fri, 13 Sep 2019 07:14:40 +0000 (09:14 +0200)
This patch move the grepping test inside the if for not failling due to
set -xe
For the same reason, harden the code checking if git clone was
successfull.

Change-Id: Idb0619c4e90c9a3a0654a024fbd2166e49df98c6
Bug-AGL: SPEC-2703
Signed-off-by: Corentin LABBE <clabbe@baylibre.com>
jjb/common/include-agl-lava-jobs-submit.sh

index 8248213..dbb1f93 100644 (file)
@@ -68,25 +68,25 @@ echo "####"
 handle_skiplist() {
        SKIPLIST=skiplist
        # detect job type (apps vs non-apps) and get skiplist
-       echo $JOB_NAME | grep -q 'ci-platform'
-       if [ $? -eq 0 ];then
-               git clone https://${GERRIT_HOST}/gerrit/src/qa-testdefinitions.git
-               if [ $? -ne ];then
+       if [ ! -z "$(echo $JOB_NAME | grep 'ci-platform')" ];then
+               git clone https://${GERRIT_HOST}/gerrit/src/qa-testdefinitions.git || true
+               if [ ! -e qa-testdefinitions ];then
                        echo "ERROR: fail to get qa-testdefinitions"
-                       return 1
+                       return 0
                fi
                SKIPDIR=qa-testdefinitions/skiplists/
                SKIPFILE=common
                CK_REPO_NAME="qa-testdefinitions"
        else
-               git clone https://${GERRIT_HOST}/gerrit/${GERRIT_PROJECT}.git
-               if [ $? -ne ];then
+               git clone https://${GERRIT_HOST}/gerrit/${GERRIT_PROJECT}.git || true
+               # GERRIT_PROJECT could have a / in it
+               CK_REPO_NAME="$(basename ${GERRIT_PROJECT})"
+               if [ ! -e $CK_REPO_NAME ];then
                        echo "ERROR: fail to get $GERRIT_PROJECT"
-                       return 1
+                       return 0
                fi
-               SKIPDIR=${GERRIT_PROJECT}/
+               SKIPDIR=${CK_REPO_NAME}/
                SKIPFILE=.aglci
-               CK_REPO_NAME="${GERRIT_PROJECT}"
        fi
        for skipfile in $SKIPFILE $MACHINE ${GERRIT_PROJECT}
        do
@@ -111,8 +111,7 @@ handle_skiplist() {
        do
                # Check if fail are "normal/accepted"
                TESTNAME=$(echo $testline | cut -d' ' -f2)
-               grep -q $TESTNAME $SKIPLIST
-               if [ $? -ne 0 ];then
+               if [ -z "$(grep $TESTNAME $SKIPLIST)" ];then
                        echo "DEBUG: $TESNAME not in skiplist"
                        GOODJOB=0
                else