frappy/ci/Jenkinsfile
Björn Pedersen c57d92eb20 Fix git reference for docker env
Change-Id: Iaae09aef0838470753d4c80d43ba5812f23d11b6
Reviewed-on: https://forge.frm2.tum.de/review/18945
Reviewed-by: Bjoern Pedersen <bjoern.pedersen@frm2.tum.de>
Tested-by: Bjoern Pedersen <bjoern.pedersen@frm2.tum.de>
2018-09-26 09:15:26 +02:00

169 lines
4.7 KiB
Groovy

properties([
buildDiscarder(logRotator(artifactDaysToKeepStr: '',
artifactNumToKeepStr: '',
daysToKeepStr: '',
numToKeepStr: '50')),
parameters([
string(defaultValue: 'sine2020/secop/playground',
description: '', name: 'GERRIT_PROJECT'),
string(defaultValue: 'master',
description: '', name: 'GERRIT_BRANCH'),
string(defaultValue: 'refs/heads/master',
description: '', name: 'GERRIT_REFSPEC'),
choice(choices: '''\
patchset-created
ref-updated
change-merged''',
description: '', name: 'GERRIT_EVENT'),
choice(choices: '''\
patchset-created
ref-updated
change-merged''',
description: '', name: 'GERRIT_EVENT_TYPE')])
])
this.verifyresult = [:]
def run_tests(pyver)
{
writeFile file: 'setup.cfg', text: '''
[tool:pytest]
addopts = --junit-xml=pytest.xml --junit-prefix=''' + pyver
def status = "OK"
verifyresult.put(pyver, 0)
try {
timeout(5) {
sh '''\
#!/bin/bash
. /home/jenkins/secopvenv/bin/activate
pip install -r requirements-dev.txt
pip install -r requirements.txt
make test
'''
verifyresult.put(pyver, 1)
}
} catch (all) {
currentBuild.result = 'FAILURE'
status = 'FAILURE'
verifyresult.put(pyver, -1)
}
gerritverificationpublisher([
verifyStatusValue: verifyresult[pyver],
verifyStatusCategory: 'test ',
verifyStatusName: 'pytest-'+pyver,
verifyStatusReporter: 'jenkins',
verifyStatusRerun: '!recheck'])
step([$class: 'JUnitResultArchiver', allowEmptyResults: true,
keepLongStdio: true, testResults: 'pytest.xml'])
if (status == 'FAILURE') {
throw new Exception('Failure in test with ' + pyver)
}
}
def run_docs() {
stage('check links') {
sh '''
. /home/jenkins/secopvenv/bin/activate
make -C doc linkcheck
'''
}
stage('build html') {
sh '''
. /home/jenkins/secopvenv/bin/activate
make -C doc html
'''
}
stage('build singlehtml') {
sh '''
. /home/jenkins/secopvenv/bin/activate
make -C doc singlehtml
'''
}
stage('build latexpdf') {
sh '''
. /home/jenkins/secopvenv/bin/activate
make -C doc latexpdf
'''
}
stage('build man') {
sh '''
. /home/jenkins/secopvenv/bin/activate
make -C doc man
'''
}
stage('store html doc for build') {
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'doc/_build/html', reportFiles: 'index.html', reportName: 'Built documentation', reportTitles: ''])
gerritverificationpublisher([
verifyStatusValue: 1,
verifyStatusCategory: 'test ',
verifyStatusName: 'doc',
verifyStatusReporter: 'jenkins',
verifyStatusRerun: '@recheck'
])
}
stage('publish') {
if (GERRIT_EVENT_TYPE == 'change-merged')
{
sh '''
rsync -rlv doc/_build/* /share/ictrl/public/doc/secop
'''
}
}
}
node("master") {
stage('clean workspace')
{
cleanWs()
}
stage('checkout') {
checkout poll: false,
scm: [$class: 'GitSCM',
branches: [[name: '${GERRIT_BRANCH}']],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'CleanCheckout'],
[$class: 'hudson.plugins.git.extensions.impl.BuildChooserSetting',
buildChooser: [$class: "com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTriggerBuildChooser"]],
],
submoduleCfg: [],
userRemoteConfigs:
[[
refspec: GERRIT_REFSPEC,
credentialsId: 'jenkins_ecdsa_x',
url: 'ssh://jenkins@forge.frm2.tum.de:29418/${GERRIT_PROJECT}']]]
sh 'git show'
}
stage('(re-)generate image') {
sh '''#!/bin/bash
git worktree add tmpmaster origin/master
cd tmpmaster
docker build --target base --tag secop_base:latest ci
docker build --target docs --tag secop_docs:latest ci
cd ..
rm -rf tmpmaster
'''
}
stage('execute tests') {
parallel 'Test': {
img = docker.image('secop_base:latest')
img.inside {
run_tests('python2')
}},
'Docs': {
img = docker.image('secop_docs:latest')
img.inside {
run_docs()
}}
}
}