-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
112 lines (110 loc) · 4.27 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
100
101
102
103
104
105
106
107
108
109
110
111
112
properties([
buildDiscarder(
logRotator(
artifactDaysToKeepStr: '',
artifactNumToKeepStr: '',
daysToKeepStr: '14',
numToKeepStr: '10',
)
),
// Make new builds terminate existing builds
disableConcurrentBuilds(
abortPrevious: true,
)
])
pipeline {
agent {
// To run on a specific node, e.g. for a specific architecture, add `label '...'`.
docker {
alwaysPull true
image 'lsstts/develop-env:develop'
args "--entrypoint=''"
}
}
environment {
// Python module name.
MODULE_NAME = 'lsst.ts.config.mtcalsys'
WORK_BRANCHES = "${GIT_BRANCH} ${CHANGE_BRANCH} develop"
LSST_IO_CREDS = credentials('lsst-io')
XML_REPORT_PATH = 'jenkinsReport/report.xml'
}
stages {
stage ('Update branches of required packages') {
steps {
// When using the docker container, we need to change the WHOME path
// to WORKSPACE to have the authority to install the packages.
withEnv(["WHOME=${env.WORKSPACE}"]) {
sh """
source /home/saluser/.setup_dev.sh || echo "Loading env failed; continuing..."
function update_package {
# Update the specified T&S package
cd /home/saluser/repos/\${1}
/home/saluser/.checkout_repo.sh ${WORK_BRANCHES}
git pull
}
function update_or_clone_package {
# Update the specified T&S package if it exists,
# else git clone it from https://github.com/lsst-ts/\${1}.git
if [ -d "/home/saluser/repos/\${1}" ]; then
update_package "\${1}"
else
# Package does not exist; clone it
cd /home/saluser/repos
git clone https://github.com/lsst-ts/\${1}.git
cd /home/saluser/repos/\${1}
/home/saluser/.checkout_repo.sh ${WORK_BRANCHES}
pip install --ignore-installed -e .
eups declare -r . -t current
fi
}
# Update base required packages
update_package ts_idl
update_package ts_sal
update_package ts_salobj
update_package ts_utils
update_package ts_xml
# Update dependencies for the CSC packages
update_package ts_simactuators
update_package ts_tcpip
# Update CSC packages
update_or_clone_package ts_cbp
update_or_clone_package ts_linearstage
update_or_clone_package ts_tunablelaser
"""
}
}
}
stage('Run unit tests') {
steps {
withEnv(["WHOME=${env.WORKSPACE}"]) {
sh """
source /home/saluser/.setup_dev.sh || echo "Loading env failed; continuing..."
setup -r .
pytest --cov-report html --cov=${env.MODULE_NAME} --junitxml=${env.XML_REPORT_PATH}
"""
}
}
}
}
post {
always {
// The path of xml needed by JUnit is relative to the workspace.
junit 'jenkinsReport/*.xml'
// Publish the HTML report.
publishHTML (
target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'jenkinsReport',
reportFiles: 'index.html',
reportName: "Coverage Report"
]
)
}
cleanup {
// Clean up the workspace.
deleteDir()
}
}
}