diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab
index ff0030d3c4..4954cc141e 100644
--- a/ci-scripts/Jenkinsfile-gitlab
+++ b/ci-scripts/Jenkinsfile-gitlab
@@ -290,6 +290,17 @@ pipeline {
}
if ("MERGE".equals(env.gitlabActionType)) {
sh "./ci-scripts/oai-ci-vm-tool report-build --workspace $WORKSPACE --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger merge-request --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}"
+ // If the merge request has introduced more CPPCHECK errors or warnings, notifications in GitLab
+ if (fileExists('oai_cppcheck_added_errors.txt')) {
+ def ret=readFile('./oai_cppcheck_added_errors.txt').trim();
+ if ("0".equals(ret)) {
+ echo "No added cppcheck warnings/errors in this merge request"
+ } else {
+ def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): Some modified files in Merge Request MAY have INTRODUCED up to " + ret + " CPPCHECK errors/warnings"
+ addGitLabMRComment comment: message
+ }
+ }
+ // If the merge request has introduced compilation warnings, notifications in GitLab
sh "./ci-scripts/checkAddedWarnings.sh --src-branch ${env.gitlabSourceBranch} --target-branch ${env.gitlabTargetBranch}"
def res=readFile('./oai_warning_files.txt').trim();
if ("0".equals(res)) {
diff --git a/ci-scripts/reportBuildLocally.sh b/ci-scripts/reportBuildLocally.sh
index 08d2f78443..3e385fb810 100755
--- a/ci-scripts/reportBuildLocally.sh
+++ b/ci-scripts/reportBuildLocally.sh
@@ -218,6 +218,22 @@ function sca_summary_table_header {
echo "
$2
" >> ./build_results.html
NB_ERRORS=`egrep -c "severity=\"error\"" $1`
NB_WARNINGS=`egrep -c "severity=\"warning\"" $1`
+ ADDED_ERRORS="0"
+ ADDED_WARNINGS="0"
+ if [ $MR_TRIG -eq 1 ]
+ then
+ if [ -d ../../cppcheck_archives ]
+ then
+ if [ -d ../../cppcheck_archives/$JOB_NAME ]
+ then
+ ADDED_ERRORS=`diff $1 ../../cppcheck_archives/$JOB_NAME/cppcheck.xml | egrep --color=never "^<" | egrep -c "severity=\"error"`
+ ADDED_WARNINGS=`diff $1 ../../cppcheck_archives/$JOB_NAME/cppcheck.xml | egrep --color=never "^<" | egrep -c "severity=\"warning"`
+ fi
+ fi
+ local TOTAL_NUMBER=$[$ADDED_ERRORS+$ADDED_WARNINGS]
+ if [ -f $JENKINS_WKSP/oai_cppcheck_added_errors.txt ]; then rm -f $JENKINS_WKSP/oai_cppcheck_added_errors.txt; fi
+ echo "$TOTAL_NUMBER" > $JENKINS_WKSP/oai_cppcheck_added_errors.txt
+ fi
if [ $NB_ERRORS -eq 0 ] && [ $NB_WARNINGS -eq 0 ]
then
echo "
" >> ./build_results.html
@@ -227,16 +243,54 @@ function sca_summary_table_header {
if [ $NB_ERRORS -eq 0 ]
then
echo "
" >> ./build_results.html
- echo " CPPCHECK found NO error and $NB_WARNINGS warnings " >> ./build_results.html
+ if [ $PU_TRIG -eq 1 ]
+ then
+ echo " CPPCHECK found NO error and $NB_WARNINGS warnings " >> ./build_results.html
+ fi
+ if [ $MR_TRIG -eq 1 ]
+ then
+ if [ $ADDED_WARNINGS -eq 0 ]
+ then
+ echo " CPPCHECK found NO error and $NB_WARNINGS warnings " >> ./build_results.html
+ else
+ echo " CPPCHECK found NO error and $NB_WARNINGS warnings " >> ./build_results.html
+ fi
+ fi
echo "
" >> ./build_results.html
else
echo "
" >> ./build_results.html
- echo " CPPCHECK found $NB_ERRORS errors and $NB_WARNINGS warnings " >> ./build_results.html
+ if [ $PU_TRIG -eq 1 ]
+ then
+ echo " CPPCHECK found $NB_ERRORS errors and $NB_WARNINGS warnings " >> ./build_results.html
+ fi
+ if [ $MR_TRIG -eq 1 ]
+ then
+ if [ $ADDED_ERRORS -eq 0 ] && [ $ADDED_WARNINGS -eq 0 ]
+ then
+ echo " CPPCHECK found $NB_ERRORS errors and $NB_WARNINGS warnings " >> ./build_results.html
+ else
+ echo " CPPCHECK found $NB_ERRORS errors and $NB_WARNINGS warnings " >> ./build_results.html
+ echo " " >> ./build_results.html
+ echo " " >> ./build_results.html
+ echo " This Merge Request may have introduced up to $ADDED_ERRORS errors and $ADDED_WARNINGS warnings. " >> ./build_results.html
+ fi
+ fi
echo "
" >> ./build_results.html
fi
fi
+ if [ $PU_TRIG -eq 1 ]
+ then
+ if [ -d ../../cppcheck_archives ]
+ then
+ if [ -d ../../cppcheck_archives/$JOB_NAME ]
+ then
+ cp $1 ../../cppcheck_archives/$JOB_NAME
+ fi
+ fi
+ fi
echo " " >> ./build_results.html
echo "