-
Notifications
You must be signed in to change notification settings - Fork 48
/
Jenkinsfile
89 lines (80 loc) · 3.15 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
properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [
[$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: '', description: 'Revision of mbed-os to build. By default mbed-os.lib is used. To access mbed-os PR use format "pull/PR number/head"'],
[$class: 'ChoiceParameterDefinition', name: 'profile', defaultValue: "debug", choices: ["debug", "develop", "release"], description: 'Select compilation profile from list: debug, develop or release.']
]]])
if (params.mbed_os_revision == '') {
echo 'Use mbed OS revision from mbed-os.lib'
} else {
echo "Use mbed OS revision ${params.mbed_os_revision}"
if (params.mbed_os_revision.matches('pull/\\d+/head')) {
echo "Revision is a Pull Request"
}
}
echo "Use build profile: ${params.profile}"
// List of targets to compile
def targets = [
"K64F",
"K66F",
"DISCO_F769NI"
]
// Map toolchains to CI labels
def toolchains = [
ARM: "armc6",
GCC_ARM: "arm-none-eabi-gcc"
]
// Configurations
def configurations = [
LOWPAN: "6lowpan_Atmel_RF.json",
THREAD: "Thread_Atmel_RF.json",
THREAD_SLIP: "Thread_SLIP_Atmel_RF.json",
WI_SUN: "Wisun_Stm_s2lp_RF.json"
]
def stepsForParallel = [:]
// Jenkins pipeline does not support map.each, we need to use oldschool for loop
for (int i = 0; i < targets.size(); i++) {
for(int j = 0; j < toolchains.size(); j++) {
for(int k = 0; k < configurations.size(); k++) {
def target = targets.get(i)
def toolchain = toolchains.keySet().asList().get(j)
def compilerLabel = toolchains.get(toolchain)
def configurationLabel = configurations.keySet().asList().get(k)
def configurationFile = configurations.get(configurationLabel)
def stepName = "${target} ${configurationLabel} ${toolchain}"
// SLIP configuration exist only for K64F based Raspberry HAT
if ((configurationLabel == "THREAD_SLIP") && target != "K64F") {
continue;
}
stepsForParallel[stepName] = buildStep(target, compilerLabel, configurationFile, configurationLabel, toolchain)
}
}
}
timestamps {
parallel stepsForParallel
}
def buildStep(target, compilerLabel, configurationFile, configurationLabel, toolchain) {
return {
stage ("${target}_${compilerLabel}_${configurationLabel}") {
node ("${compilerLabel}") {
deleteDir()
dir("nanostack-border-router") {
checkout scm
execute("git clean -ffdx")
execute("mbed deploy --protocol ssh")
// Update mbed-os revision if requested
if (params.mbed_os_revision != '') {
dir ("mbed-os") {
if (params.mbed_os_revision.matches('pull/\\d+/head')) {
execute("git fetch origin ${params.mbed_os_revision}:_PR_")
execute("git checkout _PR_")
} else {
execute ("git checkout ${params.mbed_os_revision}")
}
}
}
execute("mbed compile --build out/${configurationLabel}/${target}/${toolchain}/ -m ${target} -t ${toolchain} --app-config ./configs/${configurationFile} --profile ${params.profile}")
}
archive '**/nanostack-border-router.bin'
}
}
}
}