Projet

Général

Profil

0001-create-a-Jenkinsfile-27159.patch

Emmanuel Cazenave, 10 octobre 2018 12:28

Télécharger (2,76 ko)

Voir les différences:

Subject: [PATCH] create a Jenkinsfile (#27159)

 Jenkinsfile | 36 ++++++++++++++++++++++++++++++++++++
 jenkins.sh  | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 Jenkinsfile
 create mode 100755 jenkins.sh
Jenkinsfile
1
@Library('eo-jenkins-lib@master') import eo.Utils
2

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

  
3
set -e
4

  
5
for DIRECTORY in "htmlcov" "venv"
6
do
7
    if [ -d "$DIRECTORY" ]; then
8
        rm -r $DIRECTORY
9
    fi
10
done
11

  
12
virtualenv --system-site-packages venv
13
PIP_BIN=venv/bin/pip
14

  
15
rm -f coverage.xml
16
rm -f test_results.xml
17
cat << _EOF_ > .coveragerc
18
[run]
19
omit = wcs/ctl/Bouncers/*.py wcs/qommon/vendor/*.py
20

  
21
[report]
22
omit = wcs/ctl/Bouncers/*.py wcs/qommon/vendor/*.py
23
_EOF_
24

  
25
# $PIP_BIN install --upgrade 'pip<8'
26
$PIP_BIN install --upgrade setuptools
27
$PIP_BIN install --upgrade pytest WebTest mock pytest-cov pyquery pytest-django
28
$PIP_BIN install --upgrade 'pylint<1.8' # 1.8 broken (cf build #3023)
29
$PIP_BIN install --upgrade 'Django==1.8' 'gadjo'
30

  
31
LC_ALL=C LC_TIME=C LANG=C PYTHONPATH=$(pwd):$PYTHONPATH venv/bin/py.test --junitxml=test_results.xml --cov-report xml --cov-report html --cov=wcs/ --cov-config .coveragerc -v tests/
32
test -f pylint.out && cp pylint.out pylint.out.prev
33
(venv/bin/pylint -f parseable --rcfile /var/lib/jenkins/pylint.wcs.rc wcs | tee pylint.out) || /bin/true
34
test -f pylint.out.prev && (diff pylint.out.prev pylint.out | grep '^[><]' | grep .py) || /bin/true
0
-