-
Notifications
You must be signed in to change notification settings - Fork 9
/
Jenkinsfile
176 lines (150 loc) · 4.21 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
@NonCPS
def cmake(path, generator=null, args) {
def strings = args.collect { k, v -> "-D${k}=${v}" }
def g = ""
if(generator != null) {
g = "-G \"${generator}\""
}
bat("cmake ${g} ${strings.join(" ")} ${path}")
}
def buildPlatform(mcu, pld) {
stage("Build MCU ${mcu} PLD ${pld}") {
cmake("../source", "MinGW Makefiles", [
JLINK_SN: env.EFM_JLINK_FM,
MOCK_COM: env.MOCK_COM_FM,
OBC_COM: env.OBC_COM_FM,
GPIO_COM: env.GPIO_COM_FM,
TARGET_MCU_PLATFORM: mcu,
TARGET_PLD_PLATFORM: pld,
CMAKE_BUILD_TYPE: 'Release',
ENABLE_LTO: 1,
COMM_SECURITY_CODE: env.SECURITY_CODE
])
bat "make pwsat boot safe_mode pwsat.hex pwsat.bin boot.bin safe_mode.bin generate_telemetry generate_exp_data generate_persistent_state"
}
}
def build() {
buildPlatform('FlightModel', 'FlightModel')
buildPlatform('EngModel', 'FlightModel')
buildPlatform('EngModel', 'DM')
bat("make flatsat_tools")
step([$class: 'ArtifactArchiver', artifacts: 'build/*/*/bin/*', fingerprint: true])
step([$class: 'ArtifactArchiver', artifacts: 'build/*/*/tools/*', fingerprint: true])
}
def unitTests() {
bat "make unit_tests"
bat "make unit_tests.run -j1"
step([$class: 'JUnitResultArchiver', testResults: 'build/EngModel/DM/unit_tests_*.xml'])
}
def reports() {
echo "Memory usage report:"
bat "make pwsat.memory_report"
publishHTML(target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: false,
reportDir: 'build/EngModel/DM/reports/memory',
reportFiles: 'index.html',
reportName: 'Memory usage'
])
bat "make generate_telemetry.run"
bat "make generate_exp_data.run"
bat "make generate_persistent_state.run"
step([$class: 'ArtifactArchiver', artifacts: 'build/*/*/reports/*', fingerprint: true])
}
def integrationTests() {
lock('hardware') {
bat "make boot.flash"
bat "make integration_tests"
step([$class: 'JUnitResultArchiver', testResults: 'build/EngModel/DM/integration-tests.xml'])
}
}
def generateDoc() {
bat "make doc"
publishHTML(target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: false,
reportDir: 'documentation/html',
reportFiles: 'index.html',
reportName: 'Source Code Documentation'
])
}
def coverage() {
cmake(".", [
ENABLE_COVERAGE: 1,
CMAKE_BUILD_TYPE: "Debug"
])
bat "make unit_tests.coverage"
publishHTML(target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: false,
reportDir: 'build/EngModel/DM/reports/coverage',
reportFiles: 'index.html',
reportName: 'Code Coverage'
])
}
node('pwsat-build') {
stage 'Checkout'
try {
dir('source') {
deleteDir()
checkout scm
}
def toolchainPath = env.ARM_TOOLCHAIN
withEnv(["PATH+TOOLCHAIN=${toolchainPath}", "PATH+SEGGER=${env.SEGGER}", "CLICOLOR_FORCE=1"]) {
dir('build') {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
deleteDir()
build()
stage 'Unit tests'
unitTests()
stage 'Reports'
reports()
stage 'Generate Documentation'
generateDoc()
stage concurrency: 1, name: 'Integration Tests'
integrationTests()
stage 'Code Coverage'
coverage()
}
}
}
} catch(err) {
currentBuild.result = 'FAILURE'
} finally {
if(currentBuild.result != null) {
def color = 'danger'
if(currentBuild.result == 'UNSTABLE')
color = 'warning'
slackSend color: color, message: "*Build ${env.JOB_NAME} #${env.BUILD_NUMBER}: ${currentBuild.result}*\n${currentBuild.absoluteUrl}", channel: 'obc-notify'
}
step([
$class: 'WarningsPublisher',
canResolveRelativePaths: false,
canRunOnFailed: true,
consoleParsers:
[
[parserName: 'GNU Make + GNU C Compiler (gcc)']
],
defaultEncoding: '',
excludePattern: 'libs/external/**/*.*',
healthy: '',
includePattern: '',
messagesPattern: '',
unHealthy: '',
useStableBuildAsReference: true
])
}
}
// if(currentBuild.result == null)
// {
// node('flatsat && obc') {
// stage('Copy to flatsat') {
// dir(env.ARTIFACTS + '\\' + env.BRANCH_NAME) {
// unarchive mapping: ['build/': '.']
// }
// }
// }
// }