From 29861e761f50daebf793a3d3a4166d9dd1fed97b Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Sat, 12 May 2018 17:56:17 +0200 Subject: [PATCH 1/2] Move Jenkins pipeline from Jenkins to repository --- Jenkinsfile | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..0b01728e8 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,93 @@ +def pys = [ + [name: 'Python 3.6', docker:'python:3.6-stretch', tox:'py36,flake8', main: true], + [name: 'Python 3.5', docker:'python:3.5-jessie', tox:'py35', main: false], + [name: 'Python 2.7', docker:'python:2.7-stretch', tox:'py27', main: false] +] + +properties([ + durabilityHint('PERFORMANCE_OPTIMIZED'), + buildDiscarder(logRotator(numToKeepStr: '5')), +]) + +Map tasks = [failFast: true] + +pys.each { py -> + tasks[py.name] = { + node { + def image + + stage("Prepare docker $py.name") { + dir('dockerbuild') { + deleteDir() + buildDockerfile(py.docker) + image = docker.build("dosage-$py.docker") + } + } + + stage("Build $py.name") { + image.inside { + checkout scm + sh ''' + git clean -fdx + git fetch --tags + ''' + + try { + sh "tox -e $py.tox" + } catch (err) { + echo "tox failed: ${err}" + currentBuild.result = 'UNSTABLE' + } + + if (py.main) { + sh """ + python setup.py sdist bdist_wheel + """ + } + } + } + + stage ("Archive $py.name") { + archiveArtifacts artifacts: '.tox/dist/*.zip', fingerprint: true + if (py.main) { + archiveArtifacts artifacts: 'dist/*', fingerprint: true + def buildVer = findFiles(glob: 'dist/*.tar.gz')[0].name.replaceFirst(/\.tar\.gz$/, '') + currentBuild.description = buildVer + + cobertura autoUpdateHealth: false, + autoUpdateStability: false, + coberturaReportFile: '.tox/cov-*.xml', + failUnhealthy: false, + failUnstable: false, + maxNumberOfBuilds: 0, + onlyStable: false, + zoomCoverageChart: false + warnings consoleParsers: [[parserName: 'flake8']] + } + junit '.tox/junit-*.xml' + } + } + } +} + +timestamps { + ansiColor('xterm') { + parallel(tasks) + } +} + +def buildDockerfile(image) { + def uid = sh(returnStdout: true, script: 'id -u').trim() + def toxInst = 'apt-get update && apt-get -y install tox' + if (image.contains('jessie')) { + toxInst = 'pip install tox' // Dirty! + } + + writeFile file: 'Dockerfile', text: """ + FROM $image + RUN $toxInst + RUN useradd -mu $uid dockerjenkins + """ +} + +// vim: set ft=groovy: From 39356bc468dd6179544b69e16b7a56828e78d4e4 Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Mon, 14 May 2018 00:50:45 +0200 Subject: [PATCH 2/2] Add windows build to Jenkinsfile --- Jenkinsfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 0b01728e8..21c456189 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,6 +51,7 @@ pys.each { py -> archiveArtifacts artifacts: '.tox/dist/*.zip', fingerprint: true if (py.main) { archiveArtifacts artifacts: 'dist/*', fingerprint: true + stash includes: 'dist/*.tar.gz', name: 'bin' def buildVer = findFiles(glob: 'dist/*.tar.gz')[0].name.replaceFirst(/\.tar\.gz$/, '') currentBuild.description = buildVer @@ -73,6 +74,7 @@ pys.each { py -> timestamps { ansiColor('xterm') { parallel(tasks) + windowsBuild() } } @@ -90,4 +92,24 @@ def buildDockerfile(image) { """ } +def windowsBuild() { + node { + deleteDir() + unstash 'bin' + docker.image('tobix/pywine').inside { + sh ''' + . /opt/mkuserwineprefix + tar xvf dist/dosage-*.tar.gz + cd dosage-* + xvfb-run sh -c " + wine py -m pip install -e .[css] && + cd scripts && + wine py -m PyInstaller -y dosage.spec; + wineserver -w" | tee log.txt + ''' + archiveArtifacts '*/scripts/dist/*' + } + } +} + // vim: set ft=groovy: