[Asterisk-code-review] CI: Add Asterisk Gates (asterisk[15])

George Joseph asteriskteam at digium.com
Thu Jul 12 17:02:01 CDT 2018


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/9427 )

Change subject: CI: Add Asterisk Gates
......................................................................

CI: Add Asterisk Gates

Change-Id: I7e2467f9120812551238d8005deb97f965279205
---
M tests/CI/buildAsterisk.sh
M tests/CI/gateTestGroups.json
M tests/CI/gates.jenkinsfile
M tests/CI/installAsterisk.sh
M tests/CI/runTestsuite.sh
M tests/CI/runUnittests.sh
D tests/CI/setupEnvironment.sh
A tests/CI/setupJenkinsEnvironment.sh
M tests/CI/unittests.jenkinsfile
9 files changed, 184 insertions(+), 122 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/tests/CI/buildAsterisk.sh b/tests/CI/buildAsterisk.sh
index 1e424fa..85f347c 100755
--- a/tests/CI/buildAsterisk.sh
+++ b/tests/CI/buildAsterisk.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 CIDIR=$(dirname $(readlink -fn $0))
 source $CIDIR/ci.functions
@@ -25,20 +25,46 @@
 	done
 }
 
-sudo mkdir -p /srv/cache/externals /srv/cache/sounds || :
-sudo chown -R jenkins:users /srv/cache
-[ ! -d tests/CI/output ] && mkdir tests/CI/output
-sudo chown -R jenkins:users tests/CI/output
+[ x"$OUTPUT_DIR" != x ] && mkdir -p "$OUTPUT_DIR" 2&> /dev/null
+
+if [ x"$CACHE_DIR" != x ] ; then
+	mkdir -p "$CACHE_DIR/sounds $CACHE_DIR/externals" 2&> /dev/null
+fi
+
+if [ ${CCACHE_DISABLE:-0} -ne 1 ] ; then
+	if [ x"$CACHE_DIR" != x ] ; then
+		mkdir -p $CACHE_DIR/ccache
+		export CCACHE_UMASK=002
+		export CCACHE_DIR=$CACHE_DIR/ccache
+	fi
+	case ":${PATH:-}:" in
+		*:/usr/lib*/ccache:*)
+			echo "Enabling ccache at $CCACHE_DIR"
+		 ;;
+		*)
+			if [ -d /usr/lib64/ccache ] ; then
+				echo "Enabling ccache at /usr/lib64/ccache with $CCACHE_DIR"
+				export PATH="/usr/lib64/ccache${PATH:+:$PATH}"
+			elif [ -d /usr/lib/ccache ] ; then
+				echo "Enabling ccache at /usr/lib/ccache with $CCACHE_DIR"
+				export PATH="/usr/lib/ccache${PATH:+:$PATH}"
+			fi
+		;;
+	esac
+fi
+
+runner ccache -s
+runner ulimit -a
 
 MAKE=`which make`
-printenv | sort
+[ -d /usr/lib64 ] && _libdir=/usr/lib64
 
-common_config_args="--sysconfdir=/etc --with-pjproject-bundled"
-common_config_args+=" --with-sounds-cache=/srv/cache/sounds --with-externals-cache=/srv/cache/externals"
+common_config_args="--prefix=/usr ${_libdir:+--libdir=${_libdir}} --sysconfdir=/etc --with-pjproject-bundled"
+common_config_args+=" ${CACHE_DIR:+--with-sounds-cache=${CACHE_DIR}/sounds --with-externals-cache=${CACHE_DIR}/externals}"
 common_config_args+=" --enable-dev-mode"
 export WGET_EXTRA_ARGS="--quiet"
 
-runner ./configure ${common_config_args} >tests/CI/output/configure.txt
+runner ./configure ${common_config_args} > ${OUTPUT_DIR:+${OUTPUT_DIR}/}configure.txt
 
 runner ${MAKE} menuselect.makeopts
 
diff --git a/tests/CI/gateTestGroups.json b/tests/CI/gateTestGroups.json
index 8c0774a..f8ce047 100644
--- a/tests/CI/gateTestGroups.json
+++ b/tests/CI/gateTestGroups.json
@@ -1,46 +1,46 @@
 [
 	{
-		"name": "ari1",
+		"name": "ari_a-d  ",
 		"dir": "tests/CI/output/ari1",
 		"testcmd": "--test-regex=tests/rest_api/[Ca-d]"
 	},
 	{
-		"name": "ari2",
+		"name": "ari_e-z  ",
 		"dir": "tests/CI/output/ari2",
 		"testcmd": "--test-regex=tests/rest_api/[e-z]"
 	},
 	{
-		"name": "pjsip1",
+		"name": "pjsip_a-f",
 		"dir": "tests/CI/output/pjsip1",
 		"testcmd": "--test-regex=tests/channels/pjsip/[a-f]"
 	},
 	{
-		"name": "pjsip2",
+		"name": "pjsip_g-r",
 		"dir": "tests/CI/output/pjsip2",
 		"testcmd": "--test-regex=tests/channels/pjsip/[g-r]"
 	},
 	{
-		"name": "pjsip3",
+		"name": "pjsip_s-z",
 		"dir": "tests/CI/output/pjsip3",
 		"testcmd": "--test-regex=tests/channels/pjsip/[s-z]"
 	},
 	{
-		"name": "sip1",
+		"name": "sip_a-r  ",
 		"dir": "tests/CI/output/sip1",
 		"testcmd": "--test-regex=tests/channels/SIP/[Sa-r]"
 	},
 	{
-		"name": "sip2",
+		"name": "sip_s-z  ",
 		"dir": "tests/CI/output/sip2",
 		"testcmd": "--test-regex=tests/channels/SIP/[s-z]"
 	},
 	{
-		"name": "iax2_local",
+		"name": "iax2_locl",
 		"dir": "tests/CI/output/iax2_local",
 		"testcmd": " -t tests/channels/iax2 -t tests/channels/local"
 	},
 	{
-		"name": "extmwi",
+		"name": "pjsip_mwi",
 		"dir": "tests/CI/output/extmwi",
 		"testcmd": "--test-regex=tests/channels/pjsip/.*mwi"
 	}
diff --git a/tests/CI/gates.jenkinsfile b/tests/CI/gates.jenkinsfile
index 30b534a..183fac1 100644
--- a/tests/CI/gates.jenkinsfile
+++ b/tests/CI/gates.jenkinsfile
@@ -42,14 +42,12 @@
 				onUnstable: false
 			]
 	}
-	options {
-	  skipDefaultCheckout true
-	}
 	
 	agent {
 		/* All of the stages need to be performed on a docker host */
 		label "swdev-docker"
 	}
+
 	stages {
 		stage ("->") {
 			/*
@@ -65,8 +63,16 @@
 				script {
 					stage ("Checkout") {
 						sh "sudo chown -R jenkins:users ."  
+						env.GERRIT_PROJECT_URL = env.GERRIT_CHANGE_URL.replaceAll(/\/[0-9]+$/, "/${env.GERRIT_PROJECT}")
+						sh "printenv | sort"
 					
 						/*
+						 * Jenkins has already automatically checked out the base branch
+						 * for this change but we now need to check out the change itself
+						 * and rebase it on the current base branch.  If the rebase fails,
+						 * that's an indication to the user that they'll need to sort their
+						 * change out.
+						 *
 						 * The Gerrit Trigger provides all the URLs and refspecs to
 						 * check out the change.
 						 */
@@ -81,7 +87,6 @@
 								[$class: 'CloneOption',
 									noTags: true,
 									depth: 10,
-									honorRefspec: true,
 									shallow: true
 								],
 								[$class: 'BuildChooserSetting',
@@ -89,24 +94,32 @@
 								]
 							],
 							userRemoteConfigs: [
-								[name: env.GERRIT_NAME, refspec: env.GERRIT_REFSPEC, url: env.GIT_URL ]
+								[name: env.GERRIT_NAME, refspec: env.GERRIT_REFSPEC, url: env.GERRIT_PROJECT_URL ]
 							]
 						]
+
+						sh "sudo tests/CI/setupJenkinsEnvironment.sh"
 					}
 
 					def images = env.DOCKER_IMAGES.split(' ')
 					def r = currentBuild.startTimeInMillis % images.length
 					def ri = images[(int)r]
 					def randomImage = env.DOCKER_REGISTRY + "/" + ri
-					def dockerOptions = "-v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw --entrypoint=''"
+					def dockerOptions = "--ulimit core=0 --ulimit nofile=10240 " +
+						" -v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw " +
+						" --entrypoint=''"
+					def outputdir = "tests/CI/output/Testsuite"
+					def img = docker.image(randomImage)
+					img.pull()
 
 					stage ("Build") {
-						docker.image(randomImage).inside(dockerOptions + " --name ${BUILD_TAG}-build") {
+						img.inside(dockerOptions + " --name ${BUILD_TAG}-build") {
 							echo 'Building..'
-							sh './tests/CI/buildAsterisk.sh'
+							env.CCACHE_DIR = "/srv/cache/ccache"
+							sh "./tests/CI/buildAsterisk.sh --output-dir=${outputdir} --cache-dir=/srv/cache"
 
 							archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,
-								artifacts: "tests/CI/output/*"
+								artifacts: "${outputdir}/*"
 						}
 					}
 
@@ -114,22 +127,23 @@
 					def parallelTasks = [ : ]
 
 					for (def testGroup in testGroups) {
-						parallelTasks[testGroup.name] = {
-							/*
-							 * Because each task is a Groovy closure, we need to
-							 * keep local references to some variables.
-							 */
-							def groupName = testGroup.name
-							def groupDir = testGroup.dir
-							def groupTestcmd = testGroup.testcmd
-							def testsuiteUrl = env.GIT_URL.replaceAll(/${GERRIT_PROJECT}$/, "testsuite")
-							
+						/*
+						 * Because each task is a Groovy closure, we need to
+						 * keep local references to some variables.
+						 */
+						def groupName = testGroup.name
+						def groupDir = testGroup.dir
+						def groupTestcmd = testGroup.testcmd
+						def testsuiteUrl = env.GERRIT_PROJECT_URL.replaceAll(/${GERRIT_PROJECT}$/, "testsuite")
+
+						parallelTasks[groupName] = {
 							stage (groupName) {
 
-								docker.image(randomImage).inside("${dockerOptions} --name ${BUILD_TAG}-${groupName}") {
+								img.inside("${dockerOptions} --name ${BUILD_TAG}-${groupName}") {
+									sh "printenv | sort"
 
 									lock("${JOB_NAME}.${NODE_NAME}.installer") {
-										sh 'sudo ./tests/CI/installAsterisk.sh'
+										sh 'sudo ./tests/CI/installAsterisk.sh  --user-group=jenkins:users'
 									}
 
 									sh "sudo rm -rf ${groupDir} || : "
@@ -148,7 +162,7 @@
 											userRemoteConfigs: [[name: env.GERRIT_NAME, url: testsuiteUrl]]
 										]
 
-									sh "tests/CI/runTestsuite.sh --testsuite-dir='${groupDir}' --test-command='${groupTestcmd}'"
+									sh "sudo tests/CI/runTestsuite.sh --testsuite-dir='${groupDir}' --test-command='${groupTestcmd}'"
 
 									archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: true,
 										artifacts: "${groupDir}/asterisk-test-suite-report.xml, ${groupDir}/logs/**, ${groupDir}/core*.txt"
@@ -156,7 +170,10 @@
 									junit testResults: "${groupDir}/asterisk-test-suite-report.xml",
 										healthScaleFactor: 1.0,
 										keepLongStdio: true
+
+									echo "Group result d: ${currentBuild.currentResult}"
 								}
+								echo "Group result s: ${currentBuild.currentResult}"
 							}
 						}
 					}
@@ -166,32 +183,48 @@
 		}
 	}
 	post {
-		always {
-			sh "sudo make distclean || : "
-			sh "sudo rm -rf tests/CI/output || : "
+		cleanup {
+			sh "sudo make distclean 2&>/dev/null || : "
+			sh "sudo rm -rf tests/CI/output  2&>/dev/null || : "
 		}
 		/*
 		 * The Gerrit Trigger will automatically post the "Verified" results back
 		 * to Gerrit but the verification publisher publishes extra stuff in the
 		 * "Code Review" section of the review.
 		 */
+		always {
+			script {
+				def cat
+				def comment
+				switch (currentBuild.currentResult) {
+					case ~/^SUCCESS$/:
+						cat = "Passed"
+						comment = ""
+						break
+					case ~/^FAILURE$/:
+						cat = "Failed"
+						comment = "Fatal Error"
+						break
+					case ~/^UNSTABLE$/:
+						cat = "Failed"
+						comment = "Tests Failed"
+						break
+				}
+
+				gerritverificationpublisher verifyStatusCategory: cat,
+					verifyStatusURL: '', verifyStatusComment: comment,
+					verifyStatusName: '', verifyStatusReporter: 'Jenkins2',
+					verifyStatusRerun: 'regate'
+			}
+		}
 		success {
-			gerritverificationpublisher verifyStatusCategory: 'Passed',
-				verifyStatusURL: '', verifyStatusComment: 'OK',
-				verifyStatusName: 'Jenkins2', verifyStatusReporter: '',
-				verifyStatusRerun: 'regate'
+			echo "Reporting ${currentBuild.currentResult} Passed"
 		}
 		failure {
-			gerritverificationpublisher verifyStatusCategory: 'Failed',
-				verifyStatusURL: '', verifyStatusComment: 'You\'re really screwed',
-				verifyStatusName: 'Jenkins2', verifyStatusReporter: '',
-				verifyStatusRerun: 'regate'
+			echo "Reporting ${currentBuild.currentResult}: Failed: Fatal Error"
 		}
 		unstable {
-			gerritverificationpublisher verifyStatusCategory: 'Failed',
-				verifyStatusURL: '', verifyStatusComment: 'You\'re screwed',
-				verifyStatusName: 'Jenkins2', verifyStatusReporter: '',
-				verifyStatusRerun: 'regate'
+			echo "Reporting ${currentBuild.currentResult}: Failed: Tests Failed"
 		}
 	}
 }
diff --git a/tests/CI/installAsterisk.sh b/tests/CI/installAsterisk.sh
index b75730f..74f5651 100755
--- a/tests/CI/installAsterisk.sh
+++ b/tests/CI/installAsterisk.sh
@@ -1,23 +1,28 @@
-#!/bin/bash
+#!/usr/bin/env bash
+
+CIDIR=$(dirname $(readlink -fn $0))
+source $CIDIR/ci.functions
+
 MAKE=`which make`
-if [ x"${@}" != x ] ; then
-	mkdir -p "${@}"
+
+if [ x"$DESTDIR" != x ] ; then
+	mkdir -p "$DESTDIR"
 fi
-destdir=${@:+DESTDIR=${@}}
+destdir=${DESTDIR:+DESTDIR=$DESTDIR}
 
 ${MAKE} ${destdir} install || ${MAKE} ${destdir} NOISY_BUILD=yes install || exit 1
 ${MAKE} ${destdir} samples
-if [ -n "${@}" ] ; then
-	sed -i -r -e "s@\[directories\]\(!\)@[directories]@g" $@/etc/asterisk/asterisk.conf
-	sed -i -r -e "s@ /(var|etc|usr)/@ ${@}/\1/@g" $@/etc/asterisk/asterisk.conf
+if [ x"$DESTDIR" != x ] ; then
+	sed -i -r -e "s@\[directories\]\(!\)@[directories]@g" $DESTDIR/etc/asterisk/asterisk.conf
+	sed -i -r -e "s@ /(var|etc|usr)/@ $DESTDIR/\1/@g" $DESTDIR/etc/asterisk/asterisk.conf
 fi
 
 set +e
-chown -R jenkins:users ${@}/var/lib/asterisk
-chown -R jenkins:users ${@}/var/spool/asterisk
-chown -R jenkins:users ${@}/var/log/asterisk
-chown -R jenkins:users ${@}/var/run/asterisk
-chown -R jenkins:users ${@}/etc/asterisk
-[ ! -d ${@}/tmp/asterisk-jenkins ] && mkdir ${@}/tmp/asterisk-jenkins
-chown -R jenkins:users ${@}/tmp/asterisk-jenkins
-ldconfig
\ No newline at end of file
+if [ x"$USER_GROUP" != x ] ; then
+	chown -R $USER_GROUP $DESTDIR/var/lib/asterisk
+	chown -R $USER_GROUP $DESTDIR/var/spool/asterisk
+	chown -R $USER_GROUP $DESTDIR/var/log/asterisk
+	chown -R $USER_GROUP $DESTDIR/var/run/asterisk
+	chown -R $USER_GROUP $DESTDIR/etc/asterisk
+fi
+ldconfig
diff --git a/tests/CI/runTestsuite.sh b/tests/CI/runTestsuite.sh
index a84a12c..5c7a479 100755
--- a/tests/CI/runTestsuite.sh
+++ b/tests/CI/runTestsuite.sh
@@ -5,18 +5,13 @@
 
 pushd $TESTSUITE_DIR
 
-sudo ./cleanup-test-temnants.sh
-sudo chown -R jenkins:users .
-
-runner sudo PYTHONPATH=./lib/python/ ./runtests.py --cleanup ${TEST_COMMAND} || :
-
-if [ -f asterisk-test-suite-report.xml ]  ; then
-	sudo chown jenkins:users asterisk-test-suite-report.xml
-fi
+./cleanup-test-remnants.sh
+export PYTHONPATH=./lib/python/
+runner ./runtests.py --cleanup ${TEST_COMMAND} | contrib/scripts/pretty_print --no-color --no-timer --term-width=120 --show-errors || :
 
 if [ -f core* ] ; then
 	echo "*** Found a core file after running unit tests ***"
-	sudo /var/lib/asterisk/scripts/ast_coredumper --no-default-search core*
+	/var/lib/asterisk/scripts/ast_coredumper --no-default-search core*
 	exit 1
 fi
 
diff --git a/tests/CI/runUnittests.sh b/tests/CI/runUnittests.sh
index a463e15..e8a8f2c 100755
--- a/tests/CI/runUnittests.sh
+++ b/tests/CI/runUnittests.sh
@@ -46,11 +46,11 @@
 OUTPUTFILE=${OUTPUT_XML:-${OUTPUTDIR}/unittests-results.xml}
 
 [ ! -d ${OUTPUTDIR} ] && mkdir -p $OUTPUTDIR
-sudo chown -R jenkins:users $OUTPUTDIR
+[ x"$USER_GROUP" != x ] && sudo chown -R $USER_GROUP $OUTPUTDIR
 
 rm -rf $ASTETCDIR/extensions.{ael,lua} || :
 
-runner sudo $ASTERISK -U jenkins -G users -gn -C $CONFFILE
+runner sudo $ASTERISK ${USER_GROUP:+-U ${USER_GROUP%%:*} -G ${USER_GROUP##*:}} -gn -C $CONFFILE
 sleep 3
 runner $ASTERISK -rx "core waitfullybooted" -C $CONFFILE
 sleep 1
@@ -61,7 +61,7 @@
 
 runner rsync -vaH $DESTDIR/var/log/asterisk/. $OUTPUTDIR
 
-sudo chown -R jenkins:users $OUTPUTDIR
+[ x"$USER_GROUP" != x ] && sudo chown -R $USER_GROUP $OUTPUTDIR
 if [ -f core* ] ; then
 	echo "*** Found a core file after running unit tests ***"
 	$DESTDIR/var/lib/asterisk/scripts/ast_coredumper --no-default-search core*
diff --git a/tests/CI/setupEnvironment.sh b/tests/CI/setupEnvironment.sh
deleted file mode 100755
index eef47a6..0000000
--- a/tests/CI/setupEnvironment.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env bash
-
-chmod 0750 /etc/sudoers.d
-chmod 0440 /etc/sudoers.d/jenkins
-
-chown root:root -R /root
-chmod -R go-rwx /root/.ssh
-chown -R jenkins:jenkins /home/jenkins
-chown -R jenkins:jenkins /srv/cache
-chown -R jenkins:jenkins /srv/jenkins
-chown -R jenkins:jenkins /srv/git
-chmod -R go-rwx /home/jenkins/.ssh
-chmod -R go-rwx /home/jenkins/.ssh/authorized_keys
diff --git a/tests/CI/setupJenkinsEnvironment.sh b/tests/CI/setupJenkinsEnvironment.sh
new file mode 100755
index 0000000..63da6c9
--- /dev/null
+++ b/tests/CI/setupJenkinsEnvironment.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+mkdir -p /srv/cache/externals /srv/cache/sounds /srv/cache/ccache || :
+chown -R jenkins:users /srv/cache
+chmod g+rw /srv/cache/ccache
+chmod g+s /srv/cache/ccache
+mkdir -p tests/CI/output || :
+chown -R jenkins:users tests/CI/output
diff --git a/tests/CI/unittests.jenkinsfile b/tests/CI/unittests.jenkinsfile
index 7486823..d9f28e7 100644
--- a/tests/CI/unittests.jenkinsfile
+++ b/tests/CI/unittests.jenkinsfile
@@ -20,8 +20,6 @@
 		gerrit customUrl: '',
 			commentTextParameterMode: 'PLAIN',
 			commitMessageParameterMode: 'PLAIN',
-			gerritBuildStartedVerifiedValue: 0,
-			gerritBuildNotBuiltVerifiedValue: 0,
 			gerritBuildSuccessfulVerifiedValue: 1,
 			gerritBuildFailedVerifiedValue: -1,
 			gerritBuildUnstableVerifiedValue: -1,
@@ -53,7 +51,7 @@
 	}
 
 	stages {
-		stage ("Unit Tests-->") {
+		stage ("->") {
 			/*
 			 * Jenkins will try to automatically rebuild this job when
 			 * the jenkinsfile changes but since this job is dependent on
@@ -65,7 +63,10 @@
 			steps {
 				script {
 					stage ("Checkout") {
-						sh "sudo chown -R jenkins:users ."  
+						sh "sudo chown -R jenkins:users ."
+						env.GERRIT_PROJECT_URL = env.GERRIT_CHANGE_URL.replaceAll(/\/[0-9]+$/, "/${env.GERRIT_PROJECT}")
+						sh "printenv | sort"
+
 						/*
 						 * Jenkins has already automatically checked out the base branch
 						 * for this change but we now need to check out the change itself
@@ -76,7 +77,6 @@
 						 * The Gerrit Trigger provides all the URLs and refspecs to
 						 * check out the change.
 						 */
-						sh "sudo chown -R jenkins:users ."  
 						checkout scm: [$class: 'GitSCM',
 							branches: [[name: env.GERRIT_BRANCH ]],
 							extensions: [
@@ -88,7 +88,6 @@
 								[$class: 'CloneOption',
 									noTags: true,
 									depth: 10,
-									honorRefspec: true,
 									shallow: true
 								],
 								[$class: 'BuildChooserSetting',
@@ -96,37 +95,44 @@
 								]
 							],
 							userRemoteConfigs: [
-								[name: env.GERRIT_NAME, refspec: env.GERRIT_REFSPEC, url: env.GIT_URL ]
+								[name: env.GERRIT_NAME, refspec: env.GERRIT_REFSPEC, url: env.GERRIT_PROJECT_URL ]
 							]
 						]
+
+						sh "sudo tests/CI/setupJenkinsEnvironment.sh"
 					}
 
 					def images = env.DOCKER_IMAGES.split(' ')
 					def r = currentBuild.startTimeInMillis % images.length
 					def ri = images[(int)r]
 					def randomImage = env.DOCKER_REGISTRY + "/" + ri;
-					def dockerOptions =
-						"-v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw" +
-						 " --entrypoint='' --name ${BUILD_TAG}-build"
+					def dockerOptions = "--ulimit core=0 --ulimit nofile=10240 " +
+						" -v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw " +
+						" --entrypoint='' --name ${BUILD_TAG}-build"
 
-					docker.image(randomImage).inside(dockerOptions) {
+					def outputdir = "tests/CI/output/UnitTests"
+
+
+					def img = docker.image(randomImage)
+					img.pull()
+					img.inside(dockerOptions) {
 
 						stage ('Build') {
 							echo 'Building..'
-							sh './tests/CI/buildAsterisk.sh'
+
+							sh "./tests/CI/buildAsterisk.sh --output-dir=${outputdir} --cache-dir=/srv/cache"
 
 							archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,
-								artifacts: "tests/CI/output/*"
+								artifacts: "${outputdir}/*"
 						}
 
 						stage ('Test') {
-							def outputdir = "tests/CI/output/UnitTests"
 							def outputfile = "${outputdir}/unittests-results.xml"
 							def testcmd = "test execute all"
 
-							sh 'sudo ./tests/CI/installAsterisk.sh'
-							echo "tests/CI/runUnittests.sh --output-dir='${outputdir}' --output-xml='${outputfile}' --test-command='${testcmd}'"
-							sh "tests/CI/runUnittests.sh --output-dir='${outputdir}' --output-xml='${outputfile}' --test-command='${testcmd}'"
+							sh 'sudo ./tests/CI/installAsterisk.sh --user-group=jenkins:users'
+
+							sh "tests/CI/runUnittests.sh --user-group=jenkins:users --output-dir='${outputdir}' --output-xml='${outputfile}' --test-command='${testcmd}'"
 
 							archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: true,
 								artifacts: "${outputdir}/**"
@@ -142,8 +148,8 @@
 	}
 	post {
 		always {
-			sh "sudo make distclean || : "
-			sh "sudo rm -rf tests/CI/output || : "
+			sh "sudo make distclean 2&>/dev/null || : "
+			sh "sudo rm -rf tests/CI/output 2&>/dev/null || : "
 		}
 		/*
 		 * The Gerrit Trigger will automatically post the "Verified" results back
@@ -151,21 +157,24 @@
 		 * "Code Review" section of the review.
 	 	*/
 		success {
-			gerritverificationpublisher verifyStatusValue: 1, verifyStatusCategory: 'Passed',
+			echo "Reporting Passed"
+			gerritverificationpublisher verifyStatusCategory: 'Passed',
 				verifyStatusURL: '', verifyStatusComment: '',
-				verifyStatusName: '', verifyStatusReporter: '',
+				verifyStatusName: '', verifyStatusReporter: 'Jenkins2',
 				verifyStatusRerun: 'recheck'
 		}
 		failure {
-			gerritverificationpublisher verifyStatusValue: -1, verifyStatusCategory: 'Failed',
-				verifyStatusURL: '', verifyStatusComment: '',
-				verifyStatusName: '', verifyStatusReporter: '',
+			echo "Reporting Failed: Fatal Error"
+			gerritverificationpublisher verifyStatusCategory: 'Failed',
+				verifyStatusURL: '', verifyStatusComment: 'Fatal Error',
+				verifyStatusName: '', verifyStatusReporter: 'Jenkins2',
 				verifyStatusRerun: 'recheck'
 		}
 		unstable {
-			gerritverificationpublisher verifyStatusValue: -1, verifyStatusCategory: 'Failed',
-				verifyStatusURL: '', verifyStatusComment: '',
-				verifyStatusName: '', verifyStatusReporter: '',
+			echo "Reporting Failed: Tests Failed"
+			gerritverificationpublisher verifyStatusCategory: 'Failed',
+				verifyStatusURL: '', verifyStatusComment: 'Tests Failed',
+				verifyStatusName: '', verifyStatusReporter: 'Jenkins2',
 				verifyStatusRerun: 'recheck'
 		}
 	}

-- 
To view, visit https://gerrit.asterisk.org/9427
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: I7e2467f9120812551238d8005deb97f965279205
Gerrit-Change-Number: 9427
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180712/dc2f7a94/attachment-0001.html>


More information about the asterisk-code-review mailing list