configure build in Jenkins2

This commit is contained in:
Benjamin Dauvergne 2018-10-08 12:07:04 +02:00
parent 7a54118a4d
commit 7b2f4f2f9a
4 changed files with 78 additions and 5 deletions

39
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,39 @@
@Library('eo-jenkins-lib@master') import eo.Utils
pipeline {
agent any
stages {
stage('Unit Tests') {
steps {
sh './jenkins.sh'
}
}
stage('Packaging') {
steps {
script {
if (env.JOB_NAME == 'authentic2-auth-fc' && env.GIT_BRANCH == 'origin/master') {
sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder authentic2-auth-fc'
}
}
}
}
}
post {
always {
script {
utils = new Utils()
utils.mail_notify(currentBuild, env, 'admin+jenkins-authentic2-auth-fc@entrouvert.com')
utils.publish_coverage('coverage-*.xml')
utils.publish_coverage_native(
'index.html', 'htmlcov-coverage-dj18-pg', 'Coverage a2-auth-fc PG')
utils.publish_coverage_native(
'index.html', 'htmlcov-coverage-dj18-sqlite', 'Coverage a2-auth-fc SQLITE')
utils.publish_pylint('pylint.out')
}
junit 'junit-*.xml'
}
success {
cleanWs()
}
}
}

14
jenkins.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -e
for DIRECTORY in "htmlcov" "htmlcov-coverage-dj18-authentic-pg" "htmlcov-coverage-dj18-rbac-pg" "venv"
do
if [ -d "$DIRECTORY" ]; then
rm -r $DIRECTORY
fi
done
virtualenv venv
venv/bin/pip install tox
venv/bin/tox -rv

13
pylint.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
set -e -x
env
if [ -f /var/lib/jenkins/pylint.django.rc ]; then
PYLINT_RC=/var/lib/jenkins/pylint.django.rc
elif [ -f pylint.django.rc ]; then
PYLINT_RC=pylint.django.rc
else
echo No pylint RC found
exit 0
fi
pylint -f parseable --rcfile ${PYLINT_RC} "$@" | tee pylint.out || /bin/true

17
tox.ini
View File

@ -5,22 +5,25 @@
[tox]
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/authentic2-auth-fc/
envlist = {coverage,nocoverage}-{dj18}-{pg,sqlite}
envlist = coverage-dj18-{pg,sqlite}
[testenv]
whitelist_externals =
/bin/mv
/bin/rm
setenv =
AUTHENTIC2_SETTINGS_FILE=tests/settings.py
DJANGO_SETTINGS_MODULE=authentic2.settings
sqlite: DB_ENGINE=django.db.backends.sqlite3
pg: DB_ENGINE=django.db.backends.postgresql_psycopg2
coverage: COVERAGE=--junitxml=junit-{envname}.xml --cov-report xml --cov=src/ --cov-config .coveragerc
coverage: COVERAGE=--junitxml=junit-{envname}.xml --cov-report xml --cov-report html --cov=src/ --cov-config .coveragerc
fast: FAST=--nomigrations
usedevelop =
coverage: True
nocoverage: False
deps =
dj18: django>1.8,<1.9
dj19: django>1.8,<1.9
dj18: django-tables2<1.1
pg: psycopg2
coverage
pytest-cov
@ -36,8 +39,12 @@ deps =
pyquery
httmock
pytz
requests<=2.11.1
../authentic2
requests
git+https://git.entrouvert.org/authentic.git
commands =
./getlasso.sh
py.test {env:FAST:} {env:COVERAGE:} {posargs:tests/}
coverage: mv coverage.xml coverage-{envname}.xml
coverage: rm -rf htmlcov-{envname}
coverage: mv htmlcov htmlcov-{envname}
coverage-dj111-pg: ./pylint.sh src/authentic2-auth-fc/