Project

General

Profile

0001-jenkins-use-a-Jenkinsfile-33259.patch

Emmanuel Cazenave, 20 May 2019 03:20 PM

Download (3.55 KB)

View differences:

Subject: [PATCH] jenkins: use a Jenkinsfile (#33259)

 Jenkinsfile       | 44 ++++++++++++++++++++++++++++++++++++++++++++
 pylint.sh         | 13 +++++++++++++
 tests/settings.py |  1 +
 tox.ini           | 10 ++++++----
 4 files changed, 64 insertions(+), 4 deletions(-)
 create mode 100644 Jenkinsfile
 create mode 100755 pylint.sh
 create mode 100644 tests/settings.py
Jenkinsfile
1
@Library('eo-jenkins-lib@master') import eo.Utils
2

  
3
pipeline {
4
    agent any
5
    options { disableConcurrentBuilds() }
6
    stages {
7
        stage('Unit Tests') {
8
            steps {
9
                sh 'tox -rv'
10
            }
11
            post {
12
                always {
13
                    script {
14
                        utils = new Utils()
15
                        utils.publish_coverage('coverage.xml')
16
                        utils.publish_coverage_native('index.html')
17
                        utils.publish_pylint('pylint.out')
18
                    }
19
                    junit '*_results.xml'
20
                }
21
            }
22
        }
23
        stage('Packaging') {
24
            steps {
25
                script {
26
                    if (env.JOB_NAME == 'welco' && env.GIT_BRANCH == 'origin/master') {
27
                        sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder welco'
28
                    }
29
                }
30
            }
31
        }
32
    }
33
    post {
34
        always {
35
            script {
36
                utils = new Utils()
37
                utils.mail_notify(currentBuild, env, 'admin+jenkins-welco@entrouvert.com')
38
            }
39
        }
40
        success {
41
            cleanWs()
42
        }
43
    }
44
}
pylint.sh
1
#!/bin/sh
2

  
3
set -e -x
4
env
5
if [ -f /var/lib/jenkins/pylint.django.rc ]; then
6
	PYLINT_RC=/var/lib/jenkins/pylint.django.rc
7
elif [ -f pylint.django.rc ]; then
8
	PYLINT_RC=pylint.django.rc
9
else
10
	echo No pylint RC found
11
	exit 0
12
fi
13
pylint -f parseable --rcfile ${PYLINT_RC} "$@" | tee pylint.out || /bin/true
tests/settings.py
1
LANGUAGE_CODE = 'en-en'
tox.ini
1 1
[tox]
2
envlist = coverage-{django18,django111}
2
envlist = py27-{django18,django111}
3 3
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/welco/
4 4

  
5 5
[testenv]
......
7 7
  coverage: True
8 8
setenv =
9 9
  DJANGO_SETTINGS_MODULE=welco.settings
10
  WELCO_SETTINGS_FILE=tests/settings.py
10 11
  fast: FAST=--nomigrations
11
  coverage: COVERAGE=--junitxml=test_results.xml --cov-report xml --cov=welco/
12 12
deps =
13 13
  django18: django>=1.8,<1.9
14 14
  django18: django-taggit<0.23
......
22 22
  httmock
23 23
  python-dateutil
24 24
  pylint<1.8
25
  pylint-django<0.9
25
  pylint-django<0.8.1
26 26
  django-webtest
27 27
  pyquery
28 28
  lxml
29 29
  git+http://git.entrouvert.org/debian/django-ckeditor.git
30 30
commands =
31
  py.test {env:FAST:} {env:COVERAGE:} {posargs:tests/}
31
  django18: py.test {posargs: --junitxml=test_{envname}_results.xml tests/}
32
  django111: ./pylint.sh welco/
33
  django111: py.test {posargs: --junitxml=test_{envname}_results.xml --cov-report xml --cov-report html --cov=welco/ tests/}
32
-