Jenkinsfile: run nightly test using groovy script
Publishing of coverage must run before packaging to prevent breaking the build when packaging is restarting; but whenTriggeredBy cannot be used inside a unique stage for two list of steps, a groovy script is necessary to get all steps in the same stage.
This commit is contained in:
parent
3b1dcb4d55
commit
2ec1984adc
|
@ -7,31 +7,39 @@ pipeline {
|
|||
TMPDIR = "/tmp/${JOB_NAME.take(32)}-${BUILD_NUMBER}"
|
||||
}
|
||||
stages {
|
||||
stage('Tests (main)') {
|
||||
stage('Unit Tests') {
|
||||
steps {
|
||||
sh "mkdir -p ${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 -rv"""
|
||||
}
|
||||
}
|
||||
stage('Tests (nightly)') {
|
||||
when { triggeredBy 'TimerTrigger' }
|
||||
steps {
|
||||
sh """
|
||||
PYTESTOPTIONS=--slow \
|
||||
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 -rv"""
|
||||
sh """
|
||||
PYTESTOPTIONS=--slow \
|
||||
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 -rv -e rbac-py3-dj22"""
|
||||
script {
|
||||
if (env.JOB_NAME == 'authentic' && env.GIT_BRANCH == 'origin/main') {
|
||||
if (currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause')) {
|
||||
sh """
|
||||
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 -v -e authentic-py3-dj22-drf312 -- tests/test_api.py"""
|
||||
PYTESTOPTIONS=--slow \
|
||||
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 -rv"""
|
||||
sh """
|
||||
PYTESTOPTIONS=--slow \
|
||||
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 -rv -e rbac-py3-dj22"""
|
||||
if (env.JOB_NAME == 'authentic' && env.GIT_BRANCH == 'origin/main') {
|
||||
sh """
|
||||
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 -v -e authentic-py3-dj22-drf312 -- tests/test_api.py"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 {
|
||||
|
@ -50,11 +58,7 @@ PGPORT=`python3 -c 'import struct; import socket; s=socket.socket(); s.setsockop
|
|||
script {
|
||||
utils = new Utils()
|
||||
utils.mail_notify(currentBuild, env, 'ci+jenkins-authentic@entrouvert.org')
|
||||
utils.publish_coverage('coverage.xml')
|
||||
utils.publish_coverage_native('index.html')
|
||||
utils.publish_pylint('pylint.out')
|
||||
}
|
||||
mergeJunitResults()
|
||||
}
|
||||
cleanup {
|
||||
sh "rm -rf ${env.TMPDIR}"
|
||||
|
|
Loading…
Reference in New Issue