|
| 1 | +// List of targets to compile |
| 2 | +def morpheusTargets = [ |
| 3 | + //"LPC1768", |
| 4 | + //"NUCLEO_F401RE", |
| 5 | + //"NRF51822", |
| 6 | + "K64F" |
| 7 | + ] |
| 8 | + |
| 9 | +// Map morpheus toolchains to compiler labels on Jenkins |
| 10 | +def toolchains = [ |
| 11 | + //ARM: "armcc", |
| 12 | + GCC_ARM: "arm-none-eabi-gcc" |
| 13 | + ] |
| 14 | + |
| 15 | +// Initial maps for parallel build steps |
| 16 | +def stepsForParallel = [:] |
| 17 | + |
| 18 | +// Jenkins pipeline does not support map.each, we need to use oldschool for loop |
| 19 | +for (int i = 0; i < morpheusTargets.size(); i++) { |
| 20 | + for(int j = 0; j < toolchains.size(); j++) { |
| 21 | + def target = morpheusTargets.get(i) |
| 22 | + def toolchain = toolchains.keySet().asList().get(j) |
| 23 | + def compilerLabel = toolchains.get(toolchain) |
| 24 | + |
| 25 | + def stepName = "${target} ${toolchain}" |
| 26 | + stepsForParallel[stepName] = morpheusBuildStep(target, compilerLabel, toolchain) |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +/* Jenkins does not allow stages inside parallel execution, |
| 31 | + * https://issues.jenkins-ci.org/browse/JENKINS-26107 will solve this by adding labeled blocks |
| 32 | + */ |
| 33 | +stage "parallel build" |
| 34 | +try { |
| 35 | + // Actually run the steps in parallel - parallel takes a map as an argument, hence the above. |
| 36 | + parallel stepsForParallel |
| 37 | + |
| 38 | +} catch (err) { |
| 39 | + currentBuild.result = 'FAILURE' |
| 40 | + |
| 41 | + subject: "${env.JOB_NAME} build failed", |
| 42 | + body: "Greetings from mbed Continous integration system. This is an automatic email sent because a build has failed.\n\n\ |
| 43 | +This CI job checks the compiling of mbed-os with morpheus from Master branch.\n\n\ |
| 44 | +mbed-os build from branch ${env.BRANCH_NAME} has failed.\nSee ${env.BUILD_URL} for details\n\n\ |
| 45 | +Regards,\n\ |
| 46 | +ARM mbed Continuos Integration" |
| 47 | +} |
| 48 | + |
| 49 | +//Create yotta build steps for parallel execution |
| 50 | + def morpheusBuildStep(target, compilerLabel, toolchain) { |
| 51 | + return { |
| 52 | + node ("${compilerLabel}") { |
| 53 | + deleteDir() |
| 54 | + dir("mbed-os") { |
| 55 | + checkout scm |
| 56 | + sh "mbed deploy --protocol ssh" |
| 57 | + sh "mbed compile -m ${target} -t ${toolchain} -c" |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + } |
0 commit comments