CI: Add Asterisk Gates

Change-Id: I7e2467f9120812551238d8005deb97f965279205
This commit is contained in:
George Joseph
2018-07-12 15:34:14 -06:00
parent df67a98938
commit 1b1271c3ea
9 changed files with 184 additions and 122 deletions

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
CIDIR=$(dirname $(readlink -fn $0)) CIDIR=$(dirname $(readlink -fn $0))
source $CIDIR/ci.functions source $CIDIR/ci.functions
@@ -25,20 +25,46 @@ gen_mods() {
done done
} }
sudo mkdir -p /srv/cache/externals /srv/cache/sounds || : [ x"$OUTPUT_DIR" != x ] && mkdir -p "$OUTPUT_DIR" 2&> /dev/null
sudo chown -R jenkins:users /srv/cache
[ ! -d tests/CI/output ] && mkdir tests/CI/output if [ x"$CACHE_DIR" != x ] ; then
sudo chown -R jenkins:users tests/CI/output 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` MAKE=`which make`
printenv | sort [ -d /usr/lib64 ] && _libdir=/usr/lib64
common_config_args="--sysconfdir=/etc --with-pjproject-bundled" common_config_args="--prefix=/usr ${_libdir:+--libdir=${_libdir}} --sysconfdir=/etc --with-pjproject-bundled"
common_config_args+=" --with-sounds-cache=/srv/cache/sounds --with-externals-cache=/srv/cache/externals" common_config_args+=" ${CACHE_DIR:+--with-sounds-cache=${CACHE_DIR}/sounds --with-externals-cache=${CACHE_DIR}/externals}"
common_config_args+=" --enable-dev-mode" common_config_args+=" --enable-dev-mode"
export WGET_EXTRA_ARGS="--quiet" 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 runner ${MAKE} menuselect.makeopts

View File

@@ -1,46 +1,46 @@
[ [
{ {
"name": "ari1", "name": "ari_a-d ",
"dir": "tests/CI/output/ari1", "dir": "tests/CI/output/ari1",
"testcmd": "--test-regex=tests/rest_api/[Ca-d]" "testcmd": "--test-regex=tests/rest_api/[Ca-d]"
}, },
{ {
"name": "ari2", "name": "ari_e-z ",
"dir": "tests/CI/output/ari2", "dir": "tests/CI/output/ari2",
"testcmd": "--test-regex=tests/rest_api/[e-z]" "testcmd": "--test-regex=tests/rest_api/[e-z]"
}, },
{ {
"name": "pjsip1", "name": "pjsip_a-f",
"dir": "tests/CI/output/pjsip1", "dir": "tests/CI/output/pjsip1",
"testcmd": "--test-regex=tests/channels/pjsip/[a-f]" "testcmd": "--test-regex=tests/channels/pjsip/[a-f]"
}, },
{ {
"name": "pjsip2", "name": "pjsip_g-r",
"dir": "tests/CI/output/pjsip2", "dir": "tests/CI/output/pjsip2",
"testcmd": "--test-regex=tests/channels/pjsip/[g-r]" "testcmd": "--test-regex=tests/channels/pjsip/[g-r]"
}, },
{ {
"name": "pjsip3", "name": "pjsip_s-z",
"dir": "tests/CI/output/pjsip3", "dir": "tests/CI/output/pjsip3",
"testcmd": "--test-regex=tests/channels/pjsip/[s-z]" "testcmd": "--test-regex=tests/channels/pjsip/[s-z]"
}, },
{ {
"name": "sip1", "name": "sip_a-r ",
"dir": "tests/CI/output/sip1", "dir": "tests/CI/output/sip1",
"testcmd": "--test-regex=tests/channels/SIP/[Sa-r]" "testcmd": "--test-regex=tests/channels/SIP/[Sa-r]"
}, },
{ {
"name": "sip2", "name": "sip_s-z ",
"dir": "tests/CI/output/sip2", "dir": "tests/CI/output/sip2",
"testcmd": "--test-regex=tests/channels/SIP/[s-z]" "testcmd": "--test-regex=tests/channels/SIP/[s-z]"
}, },
{ {
"name": "iax2_local", "name": "iax2_locl",
"dir": "tests/CI/output/iax2_local", "dir": "tests/CI/output/iax2_local",
"testcmd": " -t tests/channels/iax2 -t tests/channels/local" "testcmd": " -t tests/channels/iax2 -t tests/channels/local"
}, },
{ {
"name": "extmwi", "name": "pjsip_mwi",
"dir": "tests/CI/output/extmwi", "dir": "tests/CI/output/extmwi",
"testcmd": "--test-regex=tests/channels/pjsip/.*mwi" "testcmd": "--test-regex=tests/channels/pjsip/.*mwi"
} }

View File

@@ -42,14 +42,12 @@ pipeline {
onUnstable: false onUnstable: false
] ]
} }
options {
skipDefaultCheckout true
}
agent { agent {
/* All of the stages need to be performed on a docker host */ /* All of the stages need to be performed on a docker host */
label "swdev-docker" label "swdev-docker"
} }
stages { stages {
stage ("->") { stage ("->") {
/* /*
@@ -65,8 +63,16 @@ pipeline {
script { script {
stage ("Checkout") { 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
* 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 * The Gerrit Trigger provides all the URLs and refspecs to
* check out the change. * check out the change.
*/ */
@@ -81,7 +87,6 @@ pipeline {
[$class: 'CloneOption', [$class: 'CloneOption',
noTags: true, noTags: true,
depth: 10, depth: 10,
honorRefspec: true,
shallow: true shallow: true
], ],
[$class: 'BuildChooserSetting', [$class: 'BuildChooserSetting',
@@ -89,24 +94,32 @@ pipeline {
] ]
], ],
userRemoteConfigs: [ 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 images = env.DOCKER_IMAGES.split(' ')
def r = currentBuild.startTimeInMillis % images.length def r = currentBuild.startTimeInMillis % images.length
def ri = images[(int)r] def ri = images[(int)r]
def randomImage = env.DOCKER_REGISTRY + "/" + ri 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") { stage ("Build") {
docker.image(randomImage).inside(dockerOptions + " --name ${BUILD_TAG}-build") { img.inside(dockerOptions + " --name ${BUILD_TAG}-build") {
echo 'Building..' 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, archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,
artifacts: "tests/CI/output/*" artifacts: "${outputdir}/*"
} }
} }
@@ -114,7 +127,6 @@ pipeline {
def parallelTasks = [ : ] def parallelTasks = [ : ]
for (def testGroup in testGroups) { for (def testGroup in testGroups) {
parallelTasks[testGroup.name] = {
/* /*
* Because each task is a Groovy closure, we need to * Because each task is a Groovy closure, we need to
* keep local references to some variables. * keep local references to some variables.
@@ -122,14 +134,16 @@ pipeline {
def groupName = testGroup.name def groupName = testGroup.name
def groupDir = testGroup.dir def groupDir = testGroup.dir
def groupTestcmd = testGroup.testcmd def groupTestcmd = testGroup.testcmd
def testsuiteUrl = env.GIT_URL.replaceAll(/${GERRIT_PROJECT}$/, "testsuite") def testsuiteUrl = env.GERRIT_PROJECT_URL.replaceAll(/${GERRIT_PROJECT}$/, "testsuite")
parallelTasks[groupName] = {
stage (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") { 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} || : " sh "sudo rm -rf ${groupDir} || : "
@@ -148,7 +162,7 @@ pipeline {
userRemoteConfigs: [[name: env.GERRIT_NAME, url: testsuiteUrl]] 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, archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: true,
artifacts: "${groupDir}/asterisk-test-suite-report.xml, ${groupDir}/logs/**, ${groupDir}/core*.txt" artifacts: "${groupDir}/asterisk-test-suite-report.xml, ${groupDir}/logs/**, ${groupDir}/core*.txt"
@@ -156,7 +170,10 @@ pipeline {
junit testResults: "${groupDir}/asterisk-test-suite-report.xml", junit testResults: "${groupDir}/asterisk-test-suite-report.xml",
healthScaleFactor: 1.0, healthScaleFactor: 1.0,
keepLongStdio: true keepLongStdio: true
echo "Group result d: ${currentBuild.currentResult}"
} }
echo "Group result s: ${currentBuild.currentResult}"
} }
} }
} }
@@ -166,32 +183,48 @@ pipeline {
} }
} }
post { post {
always { cleanup {
sh "sudo make distclean || : " sh "sudo make distclean 2&>/dev/null || : "
sh "sudo rm -rf tests/CI/output || : " sh "sudo rm -rf tests/CI/output 2&>/dev/null || : "
} }
/* /*
* The Gerrit Trigger will automatically post the "Verified" results back * The Gerrit Trigger will automatically post the "Verified" results back
* to Gerrit but the verification publisher publishes extra stuff in the * to Gerrit but the verification publisher publishes extra stuff in the
* "Code Review" section of the review. * "Code Review" section of the review.
*/ */
success { always {
gerritverificationpublisher verifyStatusCategory: 'Passed', script {
verifyStatusURL: '', verifyStatusComment: 'OK', def cat
verifyStatusName: 'Jenkins2', verifyStatusReporter: '', 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' verifyStatusRerun: 'regate'
} }
}
success {
echo "Reporting ${currentBuild.currentResult} Passed"
}
failure { failure {
gerritverificationpublisher verifyStatusCategory: 'Failed', echo "Reporting ${currentBuild.currentResult}: Failed: Fatal Error"
verifyStatusURL: '', verifyStatusComment: 'You\'re really screwed',
verifyStatusName: 'Jenkins2', verifyStatusReporter: '',
verifyStatusRerun: 'regate'
} }
unstable { unstable {
gerritverificationpublisher verifyStatusCategory: 'Failed', echo "Reporting ${currentBuild.currentResult}: Failed: Tests Failed"
verifyStatusURL: '', verifyStatusComment: 'You\'re screwed',
verifyStatusName: 'Jenkins2', verifyStatusReporter: '',
verifyStatusRerun: 'regate'
} }
} }
} }

View File

@@ -1,23 +1,28 @@
#!/bin/bash #!/usr/bin/env bash
CIDIR=$(dirname $(readlink -fn $0))
source $CIDIR/ci.functions
MAKE=`which make` MAKE=`which make`
if [ x"${@}" != x ] ; then
mkdir -p "${@}" if [ x"$DESTDIR" != x ] ; then
mkdir -p "$DESTDIR"
fi fi
destdir=${@:+DESTDIR=${@}} destdir=${DESTDIR:+DESTDIR=$DESTDIR}
${MAKE} ${destdir} install || ${MAKE} ${destdir} NOISY_BUILD=yes install || exit 1 ${MAKE} ${destdir} install || ${MAKE} ${destdir} NOISY_BUILD=yes install || exit 1
${MAKE} ${destdir} samples ${MAKE} ${destdir} samples
if [ -n "${@}" ] ; then if [ x"$DESTDIR" != x ] ; then
sed -i -r -e "s@\[directories\]\(!\)@[directories]@g" $@/etc/asterisk/asterisk.conf sed -i -r -e "s@\[directories\]\(!\)@[directories]@g" $DESTDIR/etc/asterisk/asterisk.conf
sed -i -r -e "s@ /(var|etc|usr)/@ ${@}/\1/@g" $@/etc/asterisk/asterisk.conf sed -i -r -e "s@ /(var|etc|usr)/@ $DESTDIR/\1/@g" $DESTDIR/etc/asterisk/asterisk.conf
fi fi
set +e set +e
chown -R jenkins:users ${@}/var/lib/asterisk if [ x"$USER_GROUP" != x ] ; then
chown -R jenkins:users ${@}/var/spool/asterisk chown -R $USER_GROUP $DESTDIR/var/lib/asterisk
chown -R jenkins:users ${@}/var/log/asterisk chown -R $USER_GROUP $DESTDIR/var/spool/asterisk
chown -R jenkins:users ${@}/var/run/asterisk chown -R $USER_GROUP $DESTDIR/var/log/asterisk
chown -R jenkins:users ${@}/etc/asterisk chown -R $USER_GROUP $DESTDIR/var/run/asterisk
[ ! -d ${@}/tmp/asterisk-jenkins ] && mkdir ${@}/tmp/asterisk-jenkins chown -R $USER_GROUP $DESTDIR/etc/asterisk
chown -R jenkins:users ${@}/tmp/asterisk-jenkins fi
ldconfig ldconfig

View File

@@ -5,18 +5,13 @@ ASTETCDIR=$DESTDIR/etc/asterisk
pushd $TESTSUITE_DIR pushd $TESTSUITE_DIR
sudo ./cleanup-test-temnants.sh ./cleanup-test-remnants.sh
sudo chown -R jenkins:users . export PYTHONPATH=./lib/python/
runner ./runtests.py --cleanup ${TEST_COMMAND} | contrib/scripts/pretty_print --no-color --no-timer --term-width=120 --show-errors || :
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
if [ -f core* ] ; then if [ -f core* ] ; then
echo "*** Found a core file after running unit tests ***" 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 exit 1
fi fi

View File

@@ -46,11 +46,11 @@ OUTPUTDIR=${OUTPUT_DIR:-tests/CI/output/}
OUTPUTFILE=${OUTPUT_XML:-${OUTPUTDIR}/unittests-results.xml} OUTPUTFILE=${OUTPUT_XML:-${OUTPUTDIR}/unittests-results.xml}
[ ! -d ${OUTPUTDIR} ] && mkdir -p $OUTPUTDIR [ ! -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} || : 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 sleep 3
runner $ASTERISK -rx "core waitfullybooted" -C $CONFFILE runner $ASTERISK -rx "core waitfullybooted" -C $CONFFILE
sleep 1 sleep 1
@@ -61,7 +61,7 @@ runner $ASTERISK -rx "core stop now" -C $CONFFILE
runner rsync -vaH $DESTDIR/var/log/asterisk/. $OUTPUTDIR 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 if [ -f core* ] ; then
echo "*** Found a core file after running unit tests ***" echo "*** Found a core file after running unit tests ***"
$DESTDIR/var/lib/asterisk/scripts/ast_coredumper --no-default-search core* $DESTDIR/var/lib/asterisk/scripts/ast_coredumper --no-default-search core*

View File

@@ -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

View File

@@ -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

View File

@@ -20,8 +20,6 @@ pipeline {
gerrit customUrl: '', gerrit customUrl: '',
commentTextParameterMode: 'PLAIN', commentTextParameterMode: 'PLAIN',
commitMessageParameterMode: 'PLAIN', commitMessageParameterMode: 'PLAIN',
gerritBuildStartedVerifiedValue: 0,
gerritBuildNotBuiltVerifiedValue: 0,
gerritBuildSuccessfulVerifiedValue: 1, gerritBuildSuccessfulVerifiedValue: 1,
gerritBuildFailedVerifiedValue: -1, gerritBuildFailedVerifiedValue: -1,
gerritBuildUnstableVerifiedValue: -1, gerritBuildUnstableVerifiedValue: -1,
@@ -53,7 +51,7 @@ pipeline {
} }
stages { stages {
stage ("Unit Tests-->") { stage ("->") {
/* /*
* Jenkins will try to automatically rebuild this job when * Jenkins will try to automatically rebuild this job when
* the jenkinsfile changes but since this job is dependent on * the jenkinsfile changes but since this job is dependent on
@@ -66,6 +64,9 @@ pipeline {
script { script {
stage ("Checkout") { 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 * Jenkins has already automatically checked out the base branch
* for this change but we now need to check out the change itself * for this change but we now need to check out the change itself
@@ -76,7 +77,6 @@ pipeline {
* The Gerrit Trigger provides all the URLs and refspecs to * The Gerrit Trigger provides all the URLs and refspecs to
* check out the change. * check out the change.
*/ */
sh "sudo chown -R jenkins:users ."
checkout scm: [$class: 'GitSCM', checkout scm: [$class: 'GitSCM',
branches: [[name: env.GERRIT_BRANCH ]], branches: [[name: env.GERRIT_BRANCH ]],
extensions: [ extensions: [
@@ -88,7 +88,6 @@ pipeline {
[$class: 'CloneOption', [$class: 'CloneOption',
noTags: true, noTags: true,
depth: 10, depth: 10,
honorRefspec: true,
shallow: true shallow: true
], ],
[$class: 'BuildChooserSetting', [$class: 'BuildChooserSetting',
@@ -96,37 +95,44 @@ pipeline {
] ]
], ],
userRemoteConfigs: [ 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 images = env.DOCKER_IMAGES.split(' ')
def r = currentBuild.startTimeInMillis % images.length def r = currentBuild.startTimeInMillis % images.length
def ri = images[(int)r] def ri = images[(int)r]
def randomImage = env.DOCKER_REGISTRY + "/" + ri; def randomImage = env.DOCKER_REGISTRY + "/" + ri;
def dockerOptions = def dockerOptions = "--ulimit core=0 --ulimit nofile=10240 " +
" -v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw " + " -v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw " +
" --entrypoint='' --name ${BUILD_TAG}-build" " --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') { stage ('Build') {
echo 'Building..' 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, archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,
artifacts: "tests/CI/output/*" artifacts: "${outputdir}/*"
} }
stage ('Test') { stage ('Test') {
def outputdir = "tests/CI/output/UnitTests"
def outputfile = "${outputdir}/unittests-results.xml" def outputfile = "${outputdir}/unittests-results.xml"
def testcmd = "test execute all" def testcmd = "test execute all"
sh 'sudo ./tests/CI/installAsterisk.sh' sh 'sudo ./tests/CI/installAsterisk.sh --user-group=jenkins:users'
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 "tests/CI/runUnittests.sh --user-group=jenkins:users --output-dir='${outputdir}' --output-xml='${outputfile}' --test-command='${testcmd}'"
archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: true, archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: true,
artifacts: "${outputdir}/**" artifacts: "${outputdir}/**"
@@ -142,8 +148,8 @@ pipeline {
} }
post { post {
always { always {
sh "sudo make distclean || : " sh "sudo make distclean 2&>/dev/null || : "
sh "sudo rm -rf tests/CI/output || : " sh "sudo rm -rf tests/CI/output 2&>/dev/null || : "
} }
/* /*
* The Gerrit Trigger will automatically post the "Verified" results back * The Gerrit Trigger will automatically post the "Verified" results back
@@ -151,21 +157,24 @@ pipeline {
* "Code Review" section of the review. * "Code Review" section of the review.
*/ */
success { success {
gerritverificationpublisher verifyStatusValue: 1, verifyStatusCategory: 'Passed', echo "Reporting Passed"
gerritverificationpublisher verifyStatusCategory: 'Passed',
verifyStatusURL: '', verifyStatusComment: '', verifyStatusURL: '', verifyStatusComment: '',
verifyStatusName: '', verifyStatusReporter: '', verifyStatusName: '', verifyStatusReporter: 'Jenkins2',
verifyStatusRerun: 'recheck' verifyStatusRerun: 'recheck'
} }
failure { failure {
gerritverificationpublisher verifyStatusValue: -1, verifyStatusCategory: 'Failed', echo "Reporting Failed: Fatal Error"
verifyStatusURL: '', verifyStatusComment: '', gerritverificationpublisher verifyStatusCategory: 'Failed',
verifyStatusName: '', verifyStatusReporter: '', verifyStatusURL: '', verifyStatusComment: 'Fatal Error',
verifyStatusName: '', verifyStatusReporter: 'Jenkins2',
verifyStatusRerun: 'recheck' verifyStatusRerun: 'recheck'
} }
unstable { unstable {
gerritverificationpublisher verifyStatusValue: -1, verifyStatusCategory: 'Failed', echo "Reporting Failed: Tests Failed"
verifyStatusURL: '', verifyStatusComment: '', gerritverificationpublisher verifyStatusCategory: 'Failed',
verifyStatusName: '', verifyStatusReporter: '', verifyStatusURL: '', verifyStatusComment: 'Tests Failed',
verifyStatusName: '', verifyStatusReporter: 'Jenkins2',
verifyStatusRerun: 'recheck' verifyStatusRerun: 'recheck'
} }
} }