-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
99 lines (98 loc) · 3.36 KB
/
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
pipeline {
agent any
stages {
stage('Prepare Python venv') {
steps {
sh '''
python3 -m venv venv
. ./venv/bin/activate
pip install pipenv
pipenv install --dev
'''
}
}
stage('Python Linting') {
steps {
sh '''
. ./venv/bin/activate
flake8 medex webserver.py --max-line-length 140
'''
}
}
stage('Python Testing') {
steps {
sh '''
. ./venv/bin/activate
export PYTHONPATH=$(pwd)
pytest --junitxml results.xml tests --cov=medex --cov-report xml
'''
}
}
stage('Setup NodeJS') {
steps {
sh '''
# Npm will fail due to BeeGFS's hardlink limitation
# (see https://doc.beegfs.io/latest/architecture/overview.html#limitations)
# in combination with an npm bug
# (see https://github.com/npm/cli/issues/5951).
# So we need a file system with unrestricted hard links.
# We use /tmp.
set -e -u
if [ -L ~/.npm ]
then
tmp_dir="$(readlink ~/.npm)"
[ -d "$tmp_dir" ] && rm -rf "$tmp_dir"
fi
rm -rf ~/.npm || true
ln -s $(mktemp -d /tmp/jenkins_medex_XXXXXXXXXX) ~/.npm
cd medex_client
npm install --save-dev
'''
}
}
stage('Linter MedEx Client') {
steps {
sh '''
cd medex_client
npm run lint
'''
}
}
stage('Test MedEx Client') {
steps {
sh '''
cd medex_client
npm run coverage
'''
}
}
stage('Check TypeScript Test Coverage') {
steps {
clover(
cloverReportDir: 'medex_client/coverage', cloverReportFileName: 'clover.xml',
healthyTarget: [methodCoverage: 70, conditionalCoverage: 80, statementCoverage: 80],
unhealthyTarget: [methodCoverage: 50, conditionalCoverage: 50, statementCoverage: 50],
failingTarget: [methodCoverage: 0, conditionalCoverage: 0, statementCoverage: 0]
)
}
}
}
post {
always {
junit 'results.xml'
recordCoverage(tools: [[parser: 'COBERTURA', pattern: 'coverage.xml']])
sh '''
if [ -L ~/.npm ]
then
tmp_dir="$(readlink ~/.npm)"
[ -d "$tmp_dir" ] && rm -rf "$tmp_dir"
fi
'''
}
failure {
emailext to: "MEDEX-KTICC@listserv.uni-heidelberg.de",
subject: "jenkins build:${currentBuild.currentResult}: ${env.JOB_NAME}",
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME}\nMore Info can be found here: ${env.BUILD_URL}"
}
}
}