forked from ska-telescope/lmc-base-classes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
66 lines (59 loc) · 2.62 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
node('docker') {
withDockerContainer(
image: 'tango-lmc-base-classes:latest',
args: '-u root'
) {
stage 'Cleanup workspace'
sh 'chmod 777 -R .'
sh 'rm -rf *'
stage 'Checkout SCM'
checkout([
$class: 'GitSCM',
branches: [[name: "refs/heads/${env.BRANCH_NAME}"]],
extensions: [[$class: 'LocalBranch']],
userRemoteConfigs: scm.userRemoteConfigs,
doGenerateSubmoduleConfigurations: false,
submoduleCfg: []
])
stage 'Install & Unit Tests'
timestamps {
timeout(time: 30, unit: 'MINUTES') {
ansiColor('xterm') {
try {
// Add a symbolic link to lmc-base-classes dir, as the Ansible scripts
// assume that is part of the path
sh 'ln -sv $WORKSPACE ../lmc-base-classes'
// use Ansible to do pip installs, using current WORKSPACE
// as the software_root
// install coverage manually, so it can be used after tests
sh '''
PARENT_DIR=`dirname $WORKSPACE`
cd ansible
ansible-playbook -i hosts install_sw.yml \
--limit "local" \
--tags install-sw-lmc-base-classes \
--tags install-sw-skabase \
--verbose \
--extra-vars software_root=$PARENT_DIR
pip install coverage
cd ..
'''
catchError {
// run tests
sh '''
python setup.py test \
--addopts="--junitxml results.xml --color=yes --cov=skabase --cov=refelt --cov-report=term --cov-config .coveragerc"
'''
}
// generate HTML coverage report
sh 'coverage html'
}
finally {
step([$class: 'JUnitResultArchiver', testResults: 'results.xml'])
archive 'htmlcov/*'
}
}
}
}
}
}