-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
117 lines (103 loc) · 3.37 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
#!groovy
pipeline {
// agent defines where the pipeline will run.
agent {
label "windows"
}
triggers {
pollSCM('H/2 * * * *')
}
// The options directive is for configuration that applies to the whole job.
options {
buildDiscarder(logRotator(numToKeepStr:'10'))
timeout(time: 60, unit: 'MINUTES')
disableConcurrentBuilds()
office365ConnectorWebhooks([[
name: "Office 365",
notifyBackToNormal: true,
startNotification: false,
notifyFailure: true,
notifySuccess: false,
notifyNotBuilt: false,
notifyAborted: false,
notifyRepeatedFailure: true,
notifyUnstable: true,
url: "${env.MSTEAMS_URL}"
]]
)
}
stages {
stage("Checkout") {
steps {
echo "Branch: ${env.BRANCH_NAME}"
checkout scm
setLatestGeniePath()
echo "python3 path: ${env.PYTHON3_PATH}"
script {
env.GIT_COMMIT = bat(returnStdout: true, script: '@git rev-parse HEAD').trim()
echo "git commit: ${env.GIT_COMMIT}"
echo "git branch name: ${env.BRANCH_NAME}"
echo "git branch: ${env.GIT_BRANCH}"
echo "git local branch: ${env.GIT_LOCAL_BRANCH}"
echo "git change id: ${env.CHANGE_ID}"
echo "git change url: ${env.CHANGE_URL}"
}
}
}
stage("Run All Tests") {
steps {
bat """
robocopy "\\\\isis.cclrc.ac.uk\\inst\$\\Kits\$\\CompGroup\\ICP\\EPICS_UTILS" "C:\\Instrument\\Apps\\EPICS_UTILS" /E /PURGE /R:2 /MT /XF "install.log" /NFL /NDL /NP
set "PATH=%PATH%;C:\\Instrument\\Apps\\EPICS_UTILS"
set PYTHON3_PATH=${env.PYTHON3_PATH}
%PYTHON3_PATH%\\Python\\python run_all_tests.py --output_dir ./test-reports
"""
}
}
stage("Collate Unit Tests") {
steps {
junit '**/test-reports/TEST-*.xml'
script {
if (fileExists('**/cobertura.xml')) {
cobertura coberturaReportFile: '**/cobertura.xml'
}
}
}
}
stage("Record Coverage") {
when { environment name: 'GIT_BRANCH', value: 'origin/master' }
steps {
script {
currentBuild.result = 'SUCCESS'
}
step([$class: 'MasterCoverageAction', scmVars: [GIT_URL: env.GIT_URL]])
}
}
stage("PR Coverage to Github") {
when { not { environment name: 'GIT_BRANCH', value: 'origin/master' }}
steps {
script {
currentBuild.result = 'SUCCESS'
}
step([$class: 'CompareCoverageAction', scmVars: [GIT_URL: env.GIT_URL]])
}
}
}
post {
always {
logParser ([
projectRulePath: 'parse_rules',
parsingRulesPath: '',
showGraphs: true,
unstableOnWarning: false,
useProjectRule: true,
])
}
}
}
def setLatestGeniePath() {
def basePath3 = '\\\\isis.cclrc.ac.uk\\inst$\\Kits\$\\CompGroup\\ICP\\genie_python_3\\'
def fileContents3 = readFile basePath3 + 'LATEST_BUILD.txt'
def pythonPath3 = basePath3 + "BUILD-$fileContents3"
env.PYTHON3_PATH = pythonPath3
}