-
Notifications
You must be signed in to change notification settings - Fork 35
/
RMC-Jenkinsfile
103 lines (95 loc) · 5.74 KB
/
RMC-Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
pipeline {
agent {
label "rmc-vosl423-x8664-build01"
}
parameters {
string(name: 'tox_args', defaultValue: '-v', description: 'Arguments passed to tox besides the environment name', )
string(name: 'pytest_args', defaultValue: '-vx -p no:timeout -m "(core or gui or share_elements) and not unstable and not user_input"', description: 'Arguments passed to pytest')
}
environment {
PATH = "/opt/python/osl42-x86_64/python2/default/bin:/opt/python/osl42-x86_64/python3/default/bin:$PATH"
LD_LIBRARY_PATH = "/opt/python/osl42-x86_64/python2/default/lib:/opt/python/osl42-x86_64/python3/default/lib:$LD_LIBRARY_PATH"
TOX_LIMITED_SHEBANG = 1
// Allows 1st build of a project to succeed, workaround for https://issues.jenkins-ci.org/browse/JENKINS-41929
tox_args = "${params.tox_args}"
pytest_args = "${params.pytest_args}"
}
stages {
stage("Run tests") {
// Run tests in parallel:
// * wrapped in Xvfb for having an X server
// * specify tox environment (py27, py36, coverage)
// * run only stable tests
// * collect pytest results in XML file
parallel {
stage('Test Python 2.7') {
steps {
timeout(time: 10, unit: 'MINUTES') {
wrap([$class: 'Xvfb', autoDisplayName: true, installationName: 'default', parallelBuild: true, screen: '1920x1200x24', timeout: 3]) {
sh "tox -e py27 $tox_args -- $pytest_args --junitxml $WORKSPACE/pytest_py27_results.xml"
}
}
}
}
stage('Test Python 3.6') {
steps {
timeout(time: 10, unit: 'MINUTES') {
wrap([$class: 'Xvfb', autoDisplayName: true, installationName: 'default', parallelBuild: true, screen: '1920x1200x24', timeout: 3]) {
sh "tox -e py36 $tox_args -- $pytest_args --junitxml $WORKSPACE/pytest_py36_results.xml"
}
}
}
}
stage('Test Python 2.7 Coverage') {
when {
anyOf { branch 'master'; branch 'develop' }
}
steps {
timeout(time: 10, unit: 'MINUTES') {
wrap([$class: 'Xvfb', autoDisplayName: true, installationName: 'default', parallelBuild: true, screen: '1920x1200x24', timeout: 3]) {
sh "tox -e coverage $tox_args -- $pytest_args > pytestout.txt"
}
}
}
}
}
}
stage('Build Documentation') {
steps {
wrap([$class: 'Xvfb', autoDisplayName: true, installationName: 'default', parallelBuild: true, screen: '1920x1200x24', timeout: 3]) {
sh 'tox -e docs'
}
// sphinx linkcheck only generates relative files, which cannot be found by recordIssues
// therefore, we need to make the path absolute
sh 'sed -i "s#.*#$WORKSPACE/doc/&#" build_doc/output.txt'
// Find warnings:
// * in the sphinx build process
// * in the sphinx linkcheck results
// * in the pytest warnings section
recordIssues filters: [excludeCategory('.*rafcon.*'), excludeCategory('redirected with Found')], tools: [sphinxBuild(), groovyScript(parserId: 'sphinx-linkcheck', pattern: 'build_doc/output.txt'), groovyScript(parserId: 'pytest', pattern: 'pytestout.txt')]
}
}
}
post {
failure {
rocketSend channel: 'rafcon-jenkins', avatar: 'https://rmc-jenkins.robotic.dlr.de/jenkins/static/ff676c77/images/headshot.png', message: ":sob: <$BUILD_URL|Build $BUILD_NUMBER> on branch '$BRANCH_NAME' *failed*! Commit: <https://rmc-github.robotic.dlr.de/common/rafcon/commit/$GIT_COMMIT|$GIT_COMMIT> :sob:", rawMessage: true
}
unstable {
junit '**/pytest_*_results.xml'
rocketSend channel: 'rafcon-jenkins', avatar: 'https://rmc-jenkins.robotic.dlr.de/jenkins/static/ff676c77/images/headshot.png', message: ":sob: <$BUILD_URL|Build $BUILD_NUMBER> on branch '$BRANCH_NAME' *failed* (unstable)! Commit: <https://rmc-github.robotic.dlr.de/common/rafcon/commit/$GIT_COMMIT|$GIT_COMMIT> :sob:", rawMessage: true
}
success {
junit '**/pytest_*_results.xml'
cobertura autoUpdateHealth: false, autoUpdateStability: false,
coberturaReportFile: 'pytest-cov_results.xml',
conditionalCoverageTargets: '70, 0, 0', lineCoverageTargets: '80, 0, 0', methodCoverageTargets: '80, 0, 0',
maxNumberOfBuilds: 0,
enableNewApi: true,
failUnhealthy: false, failUnstable: false, failNoReports: false,
sourceEncoding: 'ASCII', zoomCoverageChart: false
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'build_doc', reportFiles: 'index.html', reportName: 'Documentation', reportTitles: 'RAFCON documentation'])
rocketSend channel: 'rafcon-jenkins', avatar: 'https://rmc-jenkins.robotic.dlr.de/jenkins/static/ff676c77/images/headshot.png', message: ":tada: <$BUILD_URL|Build $BUILD_NUMBER> on branch '$BRANCH_NAME' *succeeded*! Commit: <https://rmc-github.robotic.dlr.de/common/rafcon/commit/$GIT_COMMIT|$GIT_COMMIT> :tada:", rawMessage: true
archiveArtifacts artifacts: '.tox/dist/*', fingerprint: true
}
}
}