Commit c107977f authored by carignani's avatar carignani
Browse files

attach logs to emails

parent caf487df
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -76,7 +76,9 @@ pipeline {
            }

            echo "Sending email to: ${RECIPIENT}" 
            mail to: "${RECIPIENT}",
            emailext to: "${RECIPIENT}",
                attachLog: true,
                attachmentsPattern: '**/*.log',
                subject: "[3GPP Forge] Validation succeeded: ${currentBuild.fullDisplayName}",
                body: "Your contribution to 3GPP Forge was applied successfully and, " +
                    "after running the validation process for all the files in the repository, " +
@@ -96,7 +98,9 @@ pipeline {
            }

            echo "Sending email to: ${RECIPIENT}" 
            mail to: "${RECIPIENT}",
            emailext to: "${RECIPIENT}",
                attachLog: true,
                attachmentsPattern: '**/*.log',
                subject: "[3GPP Forge] Validation failed: ${currentBuild.fullDisplayName}",
                body: "Your contribution to 3GPP Forge was applied successfully; however, " +
                    "after running the validation process for all the files in the repository, " +
+9 −5
Original line number Diff line number Diff line
@@ -94,12 +94,14 @@ pipeline {
			}

            echo "Sending email to: ${RECIPIENT}"
            mail to: "${RECIPIENT}",
            emailext to: "${RECIPIENT}",
                attachLog: true,
                attachmentsPattern: '**/*.log',
                subject: "[3GPP Forge] Validation succeeded: ${currentBuild.fullDisplayName}",
                body: "Your contribution to 3GPP Forge was applied successfully and, " +
                    "after running the validation process for all the files in the repository, " +
                    "no critial errors were detected.\n" +
                    "Detailed information in the 'Console output' at ${env.BUILD_URL}" 
                    "no critical errors were detected.\n" +
                    "Detailed information in the attachments and in 'Console output' at ${env.BUILD_URL}" 
        }

		failure {
@@ -116,12 +118,14 @@ pipeline {
			updateGitlabCommitStatus name: 'Validate OpenAPI', state: 'failed'

            echo "Sending email to: ${RECIPIENT}"
            mail to: "${RECIPIENT}",
            emailext to: "${RECIPIENT}",
                attachLog: true,
                attachmentsPattern: '**/*.log',
                subject: "[3GPP Forge] Validation failed: ${currentBuild.fullDisplayName}",
                body: "Your contribution to 3GPP Forge was applied successfully; however, " +
                    "after running the validation process for all the files in the repository, " +
                    "some errors were detected (they may, or may not be related to your own " +
                    "contribution).\nPlease check the 'Console output' at ${env.BUILD_URL}" 
                    "contribution).\nPlease check the attachments or the 'Console output' at ${env.BUILD_URL}" 
		}
	}
}
+13 −12
Original line number Diff line number Diff line
#!/bin/bash
# Copyright ETSI 2019-2020
# Copyright ETSI 2019-2021
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt

LOGFILE=openapi-validation.log
DOCKER_IMAGE=etsiforge/swagger-cli:4.0.4

if [ -x "$(command -v docker)" ] ; then
    RUN_IN_DOCKER=0
    echo "Using dockerized validator ($DOCKER_IMAGE)"
    echo "Using dockerized validator ($DOCKER_IMAGE)" | tee -a $LOGFILE
    docker pull -q "$DOCKER_IMAGE"
else
    RUN_IN_DOCKER=1
@@ -14,7 +15,7 @@ else
        echo "Validator swagger-cli not found. Quitting."
        exit 1
    else
        echo "Using local validator ($(which swagger-cli))"
        echo "Using local validator ($(which swagger-cli))" | tee -a $LOGFILE
    fi
fi

@@ -54,23 +55,23 @@ for i in ./*.yaml ; do
    fres=$(($fres||$res))
done

echo -e "\n-- Final validator returns $fres."
echo -e "\n-- Final validator returns $fres." | tee -a $LOGFILE
if [ $fres == 0 ] ; then
   echo "No errors found, all files validate the OpenAPI definition. Below the complete log."
   echo "No errors found, all files validate the OpenAPI definition. Below the complete log." | tee -a $LOGFILE
else
   echo "Some errors found, see below the details."
   echo "Some errors found, see below the details." | tee -a $LOGFILE
fi

if [ ! "$ERR" == "" ] ; then 
    echo -e "\n---- Errors detected ----"
    echo -e $ERR
    echo -e "\n---- Errors detected ----" | tee -a $LOGFILE
    echo -e $ERR  | tee -a $LOGFILE
fi

echo -e "\n---- Complete log of validation ----"
echo -e $LOG
echo -e "\n---- Complete log of validation ----" | tee -a $LOGFILE
echo -e $LOG | tee -a $LOGFILE

echo -e "\n------ Content of the folder ------"
ls
echo -e "\n------ Content of the folder ------" | tee -a $LOGFILE
ls | tee -a $LOGFILE

# Exit code needed for jenkins to know the verdict of the build

+4 −1
Original line number Diff line number Diff line
#!/bin/bash
# Copyright ETSI 2020

LOGFILE=yang-validation.log
DOCKER_IMG=etsiforge/pyang:2.4.0-3gpp-d410f57

echo "------ Switching to $1 folder --------"
@@ -20,9 +21,11 @@ fi

# This must run error-free and must display all warnings to the user
docker pull -q "${DOCKER_IMG}"
docker run --rm -v $(pwd)/yang-models:/yang "${DOCKER_IMG}" "/bin/sh" -c 'pyang --strict -p external-yams _3gpp-*.yang'
docker run --rm -v $(pwd)/yang-models:/yang "${DOCKER_IMG}" "/bin/sh" -c 'pyang --strict -p external-yams _3gpp-*.yang' 2>>$LOGFILE >>$LOGFILE
ret=$?

cat $LOGFILE

if [ $ret == 0 ] ; then
    echo "No errors found by pyang --strict validation."
fi