Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Jenkinsfile@0:8f8e8f3cbd1c, 2018-06-21 (annotated)
- Committer:
- mayur098
- Date:
- Thu Jun 21 17:50:21 2018 +0000
- Revision:
- 0:8f8e8f3cbd1c
first commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mayur098 | 0:8f8e8f3cbd1c | 1 | properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [ |
mayur098 | 0:8f8e8f3cbd1c | 2 | [$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: '', description: 'Revision of mbed-os to build. Use format "pull/PR-NUMBER/head" to access mbed-os PR'] |
mayur098 | 0:8f8e8f3cbd1c | 3 | ]]]) |
mayur098 | 0:8f8e8f3cbd1c | 4 | |
mayur098 | 0:8f8e8f3cbd1c | 5 | if (params.mbed_os_revision == '') { |
mayur098 | 0:8f8e8f3cbd1c | 6 | echo 'Use mbed OS revision from mbed-os.lib' |
mayur098 | 0:8f8e8f3cbd1c | 7 | } else { |
mayur098 | 0:8f8e8f3cbd1c | 8 | echo "Use mbed OS revisiong ${params.mbed_os_revision}" |
mayur098 | 0:8f8e8f3cbd1c | 9 | if (params.mbed_os_revision.matches('pull/\\d+/head')) { |
mayur098 | 0:8f8e8f3cbd1c | 10 | echo "Revision is a Pull Request" |
mayur098 | 0:8f8e8f3cbd1c | 11 | } |
mayur098 | 0:8f8e8f3cbd1c | 12 | } |
mayur098 | 0:8f8e8f3cbd1c | 13 | |
mayur098 | 0:8f8e8f3cbd1c | 14 | // List of targets with supported RF shields to compile |
mayur098 | 0:8f8e8f3cbd1c | 15 | def targets = [ |
mayur098 | 0:8f8e8f3cbd1c | 16 | "UBLOX_EVK_ODIN_W2": ["builtin"], |
mayur098 | 0:8f8e8f3cbd1c | 17 | "REALTEK_RTL8195AM": ["builtin"], |
mayur098 | 0:8f8e8f3cbd1c | 18 | "K64F": ["WIFI_ESP8266"], |
mayur098 | 0:8f8e8f3cbd1c | 19 | "NUCLEO_F401RE": ["WIFI_IDW0XX1"], |
mayur098 | 0:8f8e8f3cbd1c | 20 | "NUCLEO_F429ZI": ["WIFI_ESP8266"] |
mayur098 | 0:8f8e8f3cbd1c | 21 | ] |
mayur098 | 0:8f8e8f3cbd1c | 22 | |
mayur098 | 0:8f8e8f3cbd1c | 23 | // Map toolchains to compilers |
mayur098 | 0:8f8e8f3cbd1c | 24 | def toolchains = [ |
mayur098 | 0:8f8e8f3cbd1c | 25 | ARM: "armcc", |
mayur098 | 0:8f8e8f3cbd1c | 26 | GCC_ARM: "arm-none-eabi-gcc", |
mayur098 | 0:8f8e8f3cbd1c | 27 | IAR: "IAR-linux" |
mayur098 | 0:8f8e8f3cbd1c | 28 | ] |
mayur098 | 0:8f8e8f3cbd1c | 29 | |
mayur098 | 0:8f8e8f3cbd1c | 30 | // Supported RF shields |
mayur098 | 0:8f8e8f3cbd1c | 31 | def radioshields = [ |
mayur098 | 0:8f8e8f3cbd1c | 32 | "builtin", |
mayur098 | 0:8f8e8f3cbd1c | 33 | "WIFI_IDW0XX1", |
mayur098 | 0:8f8e8f3cbd1c | 34 | "WIFI_ESP8266" |
mayur098 | 0:8f8e8f3cbd1c | 35 | ] |
mayur098 | 0:8f8e8f3cbd1c | 36 | |
mayur098 | 0:8f8e8f3cbd1c | 37 | def stepsForParallel = [:] |
mayur098 | 0:8f8e8f3cbd1c | 38 | |
mayur098 | 0:8f8e8f3cbd1c | 39 | // Jenkins pipeline does not support map.each, we need to use oldschool for loop |
mayur098 | 0:8f8e8f3cbd1c | 40 | for (int i = 0; i < targets.size(); i++) { |
mayur098 | 0:8f8e8f3cbd1c | 41 | for(int j = 0; j < toolchains.size(); j++) { |
mayur098 | 0:8f8e8f3cbd1c | 42 | for(int k = 0; k < radioshields.size(); k++) { |
mayur098 | 0:8f8e8f3cbd1c | 43 | def target = targets.keySet().asList().get(i) |
mayur098 | 0:8f8e8f3cbd1c | 44 | def allowed_shields = targets.get(target) |
mayur098 | 0:8f8e8f3cbd1c | 45 | def toolchain = toolchains.keySet().asList().get(j) |
mayur098 | 0:8f8e8f3cbd1c | 46 | def compilerLabel = toolchains.get(toolchain) |
mayur098 | 0:8f8e8f3cbd1c | 47 | def radioshield = radioshields.get(k) |
mayur098 | 0:8f8e8f3cbd1c | 48 | |
mayur098 | 0:8f8e8f3cbd1c | 49 | def stepName = "${target} ${toolchain} ${radioshield}" |
mayur098 | 0:8f8e8f3cbd1c | 50 | if(allowed_shields.contains(radioshield)) { |
mayur098 | 0:8f8e8f3cbd1c | 51 | stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain, radioshield) |
mayur098 | 0:8f8e8f3cbd1c | 52 | } |
mayur098 | 0:8f8e8f3cbd1c | 53 | } |
mayur098 | 0:8f8e8f3cbd1c | 54 | } |
mayur098 | 0:8f8e8f3cbd1c | 55 | } |
mayur098 | 0:8f8e8f3cbd1c | 56 | |
mayur098 | 0:8f8e8f3cbd1c | 57 | timestamps { |
mayur098 | 0:8f8e8f3cbd1c | 58 | parallel stepsForParallel |
mayur098 | 0:8f8e8f3cbd1c | 59 | } |
mayur098 | 0:8f8e8f3cbd1c | 60 | |
mayur098 | 0:8f8e8f3cbd1c | 61 | def buildStep(target, compilerLabel, toolchain, radioShield) { |
mayur098 | 0:8f8e8f3cbd1c | 62 | return { |
mayur098 | 0:8f8e8f3cbd1c | 63 | stage ("${target}_${compilerLabel}_${radioShield}") { |
mayur098 | 0:8f8e8f3cbd1c | 64 | node ("${compilerLabel}") { |
mayur098 | 0:8f8e8f3cbd1c | 65 | deleteDir() |
mayur098 | 0:8f8e8f3cbd1c | 66 | dir("mbed-os-example-wifi") { |
mayur098 | 0:8f8e8f3cbd1c | 67 | checkout scm |
mayur098 | 0:8f8e8f3cbd1c | 68 | def config_file = "mbed_app.json" |
mayur098 | 0:8f8e8f3cbd1c | 69 | |
mayur098 | 0:8f8e8f3cbd1c | 70 | if ("${radioShield}" != "internal") { |
mayur098 | 0:8f8e8f3cbd1c | 71 | // Replace default rf shield |
mayur098 | 0:8f8e8f3cbd1c | 72 | execute("sed -i 's/\"value\": \"internal\"/\"value\": \"${radioShield}\"/' ${config_file}") |
mayur098 | 0:8f8e8f3cbd1c | 73 | } |
mayur098 | 0:8f8e8f3cbd1c | 74 | |
mayur098 | 0:8f8e8f3cbd1c | 75 | // Set mbed-os to revision received as parameter |
mayur098 | 0:8f8e8f3cbd1c | 76 | execute ("mbed deploy --protocol ssh") |
mayur098 | 0:8f8e8f3cbd1c | 77 | if (params.mbed_os_revision != '') { |
mayur098 | 0:8f8e8f3cbd1c | 78 | dir ("mbed-os") { |
mayur098 | 0:8f8e8f3cbd1c | 79 | if (params.mbed_os_revision.matches('pull/\\d+/head')) { |
mayur098 | 0:8f8e8f3cbd1c | 80 | execute("git fetch origin ${params.mbed_os_revision}:PR") |
mayur098 | 0:8f8e8f3cbd1c | 81 | execute("git checkout PR") |
mayur098 | 0:8f8e8f3cbd1c | 82 | } else { |
mayur098 | 0:8f8e8f3cbd1c | 83 | execute ("git checkout ${params.mbed_os_revision}") |
mayur098 | 0:8f8e8f3cbd1c | 84 | } |
mayur098 | 0:8f8e8f3cbd1c | 85 | } |
mayur098 | 0:8f8e8f3cbd1c | 86 | } |
mayur098 | 0:8f8e8f3cbd1c | 87 | execute("mbed new .") |
mayur098 | 0:8f8e8f3cbd1c | 88 | execute ("mbed compile --build out/${target}_${toolchain}_${radioShield}/ -m ${target} -t ${toolchain} -c --app-config ${config_file}") |
mayur098 | 0:8f8e8f3cbd1c | 89 | } |
mayur098 | 0:8f8e8f3cbd1c | 90 | stash name: "${target}_${toolchain}_${radioShield}", includes: '**/mbed-os-example-wifi.bin' |
mayur098 | 0:8f8e8f3cbd1c | 91 | archive '**/mbed-os-example-wifi.bin' |
mayur098 | 0:8f8e8f3cbd1c | 92 | step([$class: 'WsCleanup']) |
mayur098 | 0:8f8e8f3cbd1c | 93 | } |
mayur098 | 0:8f8e8f3cbd1c | 94 | } |
mayur098 | 0:8f8e8f3cbd1c | 95 | } |
mayur098 | 0:8f8e8f3cbd1c | 96 | } |