update Jenkinsfile for unit testing (#61045)

This commit is contained in:
Paul Marillonnet 2022-01-26 10:18:07 +01:00 committed by Benjamin Dauvergne
parent 48c545bbee
commit 592ffefc85
1 changed files with 26 additions and 3 deletions

29
Jenkinsfile vendored
View File

@ -2,14 +2,36 @@
pipeline {
agent any
options { disableConcurrentBuilds() }
environment {
TMPDIR = "/tmp/$BUILD_TAG"
}
stages {
stage('Unit Tests') {
steps {
sh "mkdir ${env.TMPDIR}"
sh """
python3 -m venv ${env.TMPDIR}/venv/
${env.TMPDIR}/venv/bin/pip install tox
PGPORT=`python3 -c 'import struct; import socket; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` pg_virtualenv -o fsync=off ${env.TMPDIR}/venv/bin/tox -r"""
}
post {
always {
script {
utils = new Utils()
utils.publish_coverage('coverage.xml')
utils.publish_coverage_native('index.html')
utils.publish_pylint('pylint.out')
}
mergeJunitResults()
}
}
}
stage('Packaging') {
steps {
script {
if (env.JOB_NAME == 'authentic2-auth-fedict' && env.GIT_BRANCH == 'origin/main') {
sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder -d buster,bullseye authentic2-auth-fedict'
} else if (env.GIT_BRANCH.startsWith('hotfix/')) {
sh "sudo -H -u eobuilder /usr/local/bin/eobuilder -d buster,bullseye --branch ${env.GIT_BRANCH} --hotfix authentic2-auth-fedict"
}
}
}
@ -22,7 +44,8 @@ pipeline {
utils.mail_notify(currentBuild, env, 'ci+jenkins-authentic2-auth-fedict@entrouvert.org')
}
}
success {
cleanup {
sh "find ${env.TMPDIR} -type f -delete; rm -rf ${env.TMPDIR}"
cleanWs()
}
}