Skip to content

Commit 6571f20

Browse files
authored
Refactored Jenkinsfile.
Moved general build execution steps to Jenkins internal DSL library.
1 parent 81b4af1 commit 6571f20

File tree

1 file changed

+9
-52
lines changed

1 file changed

+9
-52
lines changed

Jenkinsfile

Lines changed: 9 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,57 +13,14 @@ def toolchains = [
1313
GCC_ARM: "arm-none-eabi-gcc"
1414
]
1515

16-
// Initial maps for parallel build steps
17-
def stepsForParallel = [:]
16+
// Create a map of predefined build steps
17+
stage "generate build steps for parallel execution"
18+
def parallelSteps = mbed.createParalleSteps("mbed-os", targets, toolchains)
1819

19-
// Jenkins pipeline does not support map.each, we need to use oldschool for loop
20-
for (int i = 0; i < targets.size(); i++) {
21-
for(int j = 0; j < toolchains.size(); j++) {
22-
def target = targets.get(i)
23-
def toolchain = toolchains.keySet().asList().get(j)
24-
def compilerLabel = toolchains.get(toolchain)
20+
// Run build steps parallel, map as paramater
21+
stage "build all targets"
22+
mbed.generalCompile(parallelSteps)
2523

26-
def stepName = "${target} ${toolchain}"
27-
stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain)
28-
}
29-
}
30-
31-
/* Jenkins does not allow stages inside parallel execution,
32-
* https://issues.jenkins-ci.org/browse/JENKINS-26107 will solve this by adding labeled blocks
33-
*/
34-
stage "build mbed-os targets"
35-
// Actually run the steps in parallel - parallel takes a map as an argument, hence the above.
36-
parallel stepsForParallel
37-
38-
stage "build testapps"
39-
parallel testapp: {
40-
build job: 'ARMmbed/mbed-client-testapp/master', parameters: [[$class: 'StringParameterValue', name: 'mbed_os_revision', value: "${env.GIT_REVISION}"]]
41-
}, cliapp: {
42-
build job: 'ARMmbed/mbed-client-cliapp/master', parameters: [[$class: 'StringParameterValue', name: 'mbed_os_revision', value: "${env.GIT_REVISION}"]]
43-
}, failFast: true
44-
45-
/* End of execution, internal functions below */
46-
47-
def execute(cmd) {
48-
if (isUnix()) {
49-
sh "${cmd}"
50-
} else {
51-
bat "${cmd}"
52-
}
53-
}
54-
55-
//Create build steps for parallel execution
56-
def buildStep(target, compilerLabel, toolchain) {
57-
return {
58-
node ("${compilerLabel}") {
59-
deleteDir()
60-
dir("mbed-os") {
61-
checkout scm
62-
execute ("git log -1 --no-merges --pretty=format:'%H' > GIT_REVISION")
63-
env.GIT_REVISION = readFile ("GIT_REVISION")
64-
execute ("mbed deploy --protocol ssh")
65-
execute ("mbed test --compile -m ${target} -t ${toolchain} -c")
66-
}
67-
}
68-
}
69-
}
24+
// Run testapps, mbed-os commit hash or master as parameter
25+
stage "run mbed-os testapps"
26+
mbed.runTestApps("${env.GIT_REVISION}")

0 commit comments

Comments
 (0)