From 1c7a6693e5ad557e997e1d7ad841b7419e931ee7 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 16 Jan 2019 10:56:16 +0100 Subject: [PATCH] use a Jenkinsfile (#29776) --- Jenkinsfile | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ jenkins.sh | 17 ++++++++------- tox.ini | 3 ++- 3 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..1ad1e46 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,62 @@ +@Library('eo-jenkins-lib@master') import eo.Utils + +pipeline { + agent any + stages { + stage('Unit Tests') { + steps { + sh './jenkins.sh' + } + post { + always { + script { + utils = new Utils() + utils.publish_coverage('coverage-*.xml') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-django18-authentic', 'Coverage authentic tests') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-django18-hobo', 'Coverage hobo tests') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-django18-authentic', 'Coverage multipublik tests') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-django18-authentic', 'Coverage multitenant tests') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-django18-authentic', 'Coverage passerelle tests') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-django111-authentic', 'Coverage authentic tests') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-django111-hobo', 'Coverage hobo tests') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-django111-authentic', 'Coverage multipublik tests') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-django111-authentic', 'Coverage multitenant tests') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-django111-authentic', 'Coverage passerelle tests') + utils.publish_pylint('pylint.out') + } + junit 'junit-*.xml' + } + } + } + stage('Packaging') { + steps { + script { + if (env.JOB_NAME == 'hobo' && env.GIT_BRANCH == 'origin/master') { + sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder hobo' + } + } + } + } + } + post { + always { + script { + utils = new Utils() + utils.mail_notify(currentBuild, env, 'admin+jenkins-hobo@entrouvert.com') + } + } + success { + cleanWs() + } + } +} diff --git a/jenkins.sh b/jenkins.sh index 3291936..8add751 100755 --- a/jenkins.sh +++ b/jenkins.sh @@ -4,17 +4,18 @@ set -e # prevent hiding of errors rm -f *coverage.xml rm -f *test_results.xml +rm -f htmlcov htmlcov-* -./getlasso.sh -pip install --upgrade setuptools -pip install --upgrade pip -pip install --upgrade pylint pylint-django -pip install --upgrade tox +virtualenv venv +venv/bin/pip install --upgrade setuptools +venv/bin/pip install --upgrade pip +venv/bin/pip install --upgrade pylint pylint-django +venv/bin/pip install --upgrade tox -tox -r +venv/bin/tox -rv -./merge-junit-results.py junit-*.xml >test_results.xml -./merge-coverage.py -o coverage.xml coverage-*.xml +# ./merge-junit-results.py junit-*.xml >test_results.xml +#./merge-coverage.py -o coverage.xml coverage-*.xml test -f pylint.out && cp pylint.out pylint.out.prev diff --git a/tox.ini b/tox.ini index ee41716..f2303ad 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ setenv = passerelle: DEBIAN_CONFIG_COMMON=debian/debian_config_common.py passerelle: PASSERELLE_SETTINGS_FILE=tests_passerelle/settings.py passerelle: DJANGO_SETTINGS_MODULE=passerelle.settings - coverage: COVERAGE=--junitxml=junit-{envname}.xml --cov-report xml --cov=hobo/ --cov-config .coveragerc + coverage: COVERAGE=--junitxml=junit-{envname}.xml --cov-report xml --cov-report html --cov=hobo/ --cov-config .coveragerc fast: NOMIGRATIONS=--nomigrations deps: django18: django>=1.8,<1.9 @@ -59,3 +59,4 @@ commands = authentic: py.test {env:FAST:} {env:COVERAGE:} {env:NOMIGRATIONS:} {posargs:tests_authentic/} passerelle: py.test {env:COVERAGE:} {env:NOMIGRATIONS:} {posargs:tests_passerelle/} coverage: mv coverage.xml coverage-{envname}.xml + coverage: mv htmlcov htmlcov-{envname} -- 2.20.1