|
| 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 | + //IAR: "iar_arm", |
| 13 | + GCC_ARM: "arm-none-eabi-gcc" |
| 14 | + ] |
| 15 | + |
| 16 | +// Initial maps for parallel build steps |
| 17 | +def stepsForParallel = [:] |
| 18 | + |
| 19 | +// Jenkins pipeline does not support map.each, we need to use oldschool for loop |
| 20 | +for (int i = 0; i < morpheusTargets.size(); i++) { |
| 21 | + for(int j = 0; j < toolchains.size(); j++) { |
| 22 | + def target = morpheusTargets.get(i) |
| 23 | + def toolchain = toolchains.keySet().asList().get(j) |
| 24 | + def compilerLabel = toolchains.get(toolchain) |
| 25 | + |
| 26 | + def stepName = "${target} ${toolchain}" |
| 27 | + stepsForParallel[stepName] = morpheusBuildStep(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 | +def execute(cmd) { |
| 46 | + if (isUnix()) { |
| 47 | + sh "${cmd}" |
| 48 | + } else { |
| 49 | + bat "${cmd}" |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +//Create morpheus build steps for parallel execution |
| 54 | +def morpheusBuildStep(target, compilerLabel, toolchain) { |
| 55 | + return { |
| 56 | + node ("${compilerLabel}") { |
| 57 | + deleteDir() |
| 58 | + dir("mbed-os") { |
| 59 | + checkout scm |
| 60 | + execute ("git log -1 --no-merges --pretty=format:'%H'" > GIT_REVISION) |
| 61 | + env.GIT_REVISION = readFile "GIT_REVISION" |
| 62 | + execute ("mbed deploy --protocol ssh") |
| 63 | + execute ("mbed test --compile -m ${target} -t ${toolchain} -c") |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | +} |
0 commit comments