-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
134 lines (127 loc) · 4.82 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
properties([
buildDiscarder(
logRotator(
artifactDaysToKeepStr: '',
artifactNumToKeepStr: '',
daysToKeepStr: '14',
numToKeepStr: '10',
)
),
// Make new builds terminate existing builds
disableConcurrentBuilds(
abortPrevious: true,
)
])
pipeline {
agent {
// Run as root to avoid permission issues when creating files.
// 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.observatory.control"
// Space-separated list of SAL component names for all IDL files required.
IDL_NAMES = "--all"
// Product name for documentation upload; the associated
// documentation site is `https://{DOC_PRODUCT_NAME}.lsst.io`.
DOC_PRODUCT_NAME = "ts-observatory-control"
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 """
set +x
source /home/saluser/.setup_dev.sh || echo "Loading env failed; continuing..."
# Download git lfs files
cd ${env.WHOME}
git lfs fetch --all
git lfs checkout
cd /home/saluser/repos/
[ ! -d "./ts_cRIOpy" ] && (git clone https://github.com/lsst-ts/ts_cRIOpy.git )
for REPO in \$(ls /home/saluser/repos/); do
cd /home/saluser/repos/\${REPO}
/home/saluser/.checkout_repo.sh ${WORK_BRANCHES}
git pull
done
eups declare -r /home/saluser/repos/ts_cRIOpy -t current
# Make IDL files
make_idl_files.py ${env.IDL_NAMES} &> /dev/null
"""
}
}
}
stage('Run unit tests') {
steps {
withEnv(["WHOME=${env.WORKSPACE}"]) {
sh """
set +x
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}
"""
}
}
}
stage('Build documentation') {
steps {
withEnv(["WHOME=${env.WORKSPACE}"]) {
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
sh """
set +x
source /home/saluser/.setup_dev.sh || echo "Loading env failed; continuing..."
setup -r .
package-docs build
"""
}
}
}
}
stage('Try to upload documentation') {
steps {
withEnv(["WHOME=${env.WORKSPACE}"]) {
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
sh '''
set +x
source /home/saluser/.setup_dev.sh || echo "Loading env failed; continuing..."
setup -r .
ltd -u ${LSST_IO_CREDS_USR} -p ${LSST_IO_CREDS_PSW} upload \
--product ${DOC_PRODUCT_NAME} --git-ref ${GIT_BRANCH} --dir doc/_build/html
'''
}
}
}
}
}
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()
}
}
}