From 85447a35565e9c75497ff817169c5ba689e7bd9e Mon Sep 17 00:00:00 2001 From: Patrik Dufresne Date: Wed, 31 Jan 2018 15:16:17 -0500 Subject: [PATCH] Create a Jenkinsfile --- .gitignore | 4 +- .travis.yml | 3 ++ Jenkinsfile | 103 +++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 23 ----------- setup.py | 1 - tox.ini | 12 ++++-- 6 files changed, 117 insertions(+), 29 deletions(-) create mode 100644 Jenkinsfile delete mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 22df9765..c81ae116 100644 --- a/.gitignore +++ b/.gitignore @@ -21,8 +21,8 @@ pip-log.txt # Unit test / coverage reports .coverage .tox -coverage.xml -nosetests.xml +coverage*.xml +nosetests*.xml #Translations *.mo diff --git a/.travis.yml b/.travis.yml index 3804b426..17f7c36e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,9 @@ env: - CHERRYPY=9 - CHERRYPY=10 - CHERRYPY=11 + - CHERRYPY=12 + - CHERRYPY=13 + - CHERRYPY=14 # Make sure to exclude python3.4 + CherryPy 3.2.2 # This configuration is not supported. diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..d54838ac --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,103 @@ +def axisImages = ['jessie', 'stretch'] +def axisPython = ['py27', 'py3'] +def axisCherrypy = ['cherrypy35','cherrypy4','cherrypy5','cherrypy6','cherrypy7','cherrypy8','cherrypy9','cherrypy10','cherrypy11','cherrypy12','cherrypy13','cherrypy14'] + + +def builders = [:] +for (x in axisImages) { +for (y in axisPython) { +for (z in axisCherrypy) { + // Need to bind the label variable before the closure - can't do 'for (label in labels)' + def image = x + def python = y + def cherrypy = z + def env = "${python}-${cherrypy}" + + // Create a map to pass in to the 'parallel' step so we can fire all the builds at once + builders["${image}-${env}"] = { + node { + /* Requires the Docker Pipeline plugin to be installed */ + docker.image("ikus060/docker-debian-py2-py3:${image}").inside { + stage("${image}-${env}:Initialize") { + // Wipe working directory to make sure to build clean. + deleteDir() + // Checkout + checkout scm + echo 'Enforce timezone for tests to work.' + sh 'ln -snf /usr/share/zoneinfo/America/Montreal /etc/localtime && echo "America/Montreal" > /etc/timezone' + echo 'Upgrade python and install dependencies to avoid compiling from sources.' + sh 'apt-get update && apt-get -qq install python-pysqlite2 libldap2-dev libsasl2-dev rdiff-backup node-less' + sh 'pip install pip setuptools tox --upgrade' + } + stage("${image}-${env}:Build") { + echo 'Compile catalog and less' + sh 'python setup.py build' + } + stage("${image}-${env}:Test") { + try { + sh "tox --recreate --workdir /tmp --sitepackages -e ${env}" + } finally { + junit "nosetests-${env}.xml" + step([$class: 'CoberturaPublisher', coberturaReportFile: "coverage-${env}.xml"]) + } + } + } + } + } +}}} + +parallel builders + +node { + stage ('Publish') { + if (env.BRANCH_NAME == 'master') { + // Wipe working directory to make sure to build clean. + deleteDir() + // Checkout + checkout scm + // Define version + def pyVersion = sh( + script: 'python setup.py --version | tail -n1', + returnStdout: true + ).trim() + def version = pyVersion.replaceFirst(".dev.*", ".${BUILD_NUMBER}") + + // Push changes to git + withCredentials([usernamePassword(credentialsId: 'gitlab-jenkins', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) { + sh """ + sed -i.bak -r "s/version='(.*).dev.*'/version='${version}'/" setup.py + git config --local user.email "jenkins@patrikdufresne.com" + git config --local user.name "Jenkins" + git commit setup.py -m 'Release ${version}' + git tag '${version}' + git push http://${GIT_USERNAME}:${GIT_PASSWORD}@git.patrikdufresne.com/pdsl/rdiffweb.git --tags + """ + } + + + // Publish to pypi + docker.image("ikus060/docker-debian-py2-py3:jessie").inside { + withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'ikus060-pypi', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { + sh """ + cat > ~/.pypirc << EOF +[distutils] +index-servers = + pypi + +[pypi] +username=${USERNAME} +password=${PASSWORD} +EOF + """ + writeFile file: "/root/.pypirc", text: """ + + """ + sh 'cat /root/.pypirc' + sh 'pip install wheel --upgrade' + sh 'python setup.py sdist bdist_wheel upload -r pypi' + } + } + } + + } +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 36dcde17..00000000 --- a/requirements.txt +++ /dev/null @@ -1,23 +0,0 @@ -# rdiffweb, A web interface to rdiff-backup repositories -# Copyright (C) 2014 rdiffweb contributors -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -CherryPy>=3.5.0 -Jinja2>=2.6 -babel>=1.3 -future>=0.15.2 -pycrypto>=2.6.1 -mock>=1.3.0 -psutil>=2.1.1 \ No newline at end of file diff --git a/setup.py b/setup.py index 7fea0659..bec96a04 100644 --- a/setup.py +++ b/setup.py @@ -281,7 +281,6 @@ setup( ], # requirement for testing tests_require=[ - "tox", "mock>=1.3.0", "coverage>=4.0.1", "mockldap>=0.2.6", diff --git a/tox.ini b/tox.ini index 515d5e51..3d6e90af 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ # along with this program. If not, see . [tox] -envlist = py{27,34}-cherrypy{35,4,5,6,7,8,9,10,11},py27-cherrypy32 +envlist = py{27,3}-cherrypy{35,4,5,6,7,8,9,10,11},py27-cherrypy32 [testenv] deps= @@ -31,7 +31,10 @@ deps= cherrypy9: cherrypy>=9.0.0,<10.0.0 cherrypy10: cherrypy>=10.0.0,<11.0.0 cherrypy11: cherrypy>=11.0.0,<12.0.0 -commands=python setup.py nosetests --xunit-file=nosetests-{envname}.xml --xunit-testsuite-name={envname} + cherrypy12: cherrypy>=12.0.0,<13.0.0 + cherrypy13: cherrypy>=13.0.0,<14.0.0 + cherrypy14: cherrypy>=14.0.0,<15.0.0 +commands=python setup.py nosetests --xunit-file=nosetests-{envname}.xml --xunit-testsuite-name={envname} --cover-xml-file=coverage-{envname}.xml [travis:env] CHERRYPY = @@ -44,4 +47,7 @@ CHERRYPY = 8: cherrypy8 9: cherrypy9 10: cherrypy10 - 11: cherrypy11 \ No newline at end of file + 11: cherrypy11 + 12: cherrypy12 + 13: cherrypy13 + 14: cherrypy14 \ No newline at end of file -- GitLab