Jenkinsfile 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/env groovy
  2. pipeline {
  3. agent none
  4. stages {
  5. stage('Build') {
  6. steps {
  7. script {
  8. def build_nodes = [:]
  9. def docker_images = [
  10. nuttx: "px4io/px4-dev-nuttx:2019-02-14",
  11. ]
  12. def nuttx_builds_archive = [
  13. target: [
  14. "auavx2v1_bl",
  15. "avx_v1_bl",
  16. "crazyflie_bl",
  17. "cube_f4_bl",
  18. "mindpxv2_bl",
  19. "fmuk66v3_bl",
  20. "omnibusf4sd_bl",
  21. "px4flow_bl",
  22. "px4fmuv2_bl",
  23. "px4fmuv3_bl",
  24. "px4fmuv4_bl",
  25. "px4fmuv4pro_bl",
  26. "px4fmuv5_bl",
  27. "px4io_bl",
  28. "smartap_pro_bl"
  29. ],
  30. image: docker_images.nuttx,
  31. archive: true
  32. ]
  33. def docker_builds = [
  34. nuttx_builds_archive
  35. ]
  36. for (def build_type = 0; build_type < docker_builds.size(); build_type++) {
  37. for (def build_target = 0; build_target < docker_builds[build_type].target.size(); build_target++) {
  38. build_nodes.put(docker_builds[build_type].target[build_target],
  39. createBuildNode(docker_builds[build_type].archive, docker_builds[build_type].image, docker_builds[build_type].target[build_target])
  40. )
  41. }
  42. }
  43. parallel build_nodes
  44. } // script
  45. } // steps
  46. } // stage Build
  47. } // stages
  48. environment {
  49. CCACHE_DIR = '/tmp/ccache'
  50. CI = true
  51. }
  52. options {
  53. buildDiscarder(logRotator(numToKeepStr: '10', artifactDaysToKeepStr: '28'))
  54. timeout(time: 60, unit: 'MINUTES')
  55. }
  56. }
  57. def createBuildNode(Boolean archive, String docker_image, String target) {
  58. return {
  59. node {
  60. docker.image(docker_image).inside('-e CCACHE_BASEDIR=${WORKSPACE} -v ${CCACHE_DIR}:${CCACHE_DIR}:rw') {
  61. stage(target) {
  62. try {
  63. sh('export')
  64. checkout(scm)
  65. sh('git clean -ff -x -d .')
  66. sh('git submodule update --init --recursive --force')
  67. sh('git fetch --tags')
  68. sh('ccache -z')
  69. sh('make ' + target)
  70. sh('ccache -s')
  71. sh('make sizes')
  72. if (archive) {
  73. archiveArtifacts(allowEmptyArchive: false, artifacts: 'build/*/*.elf, build/*/*.bin, build/*/*.hex', fingerprint: true, onlyIfSuccessful: true)
  74. }
  75. }
  76. catch (exc) {
  77. throw (exc)
  78. }
  79. finally {
  80. sh('git submodule deinit -f .')
  81. sh('git clean -ff -x -d .')
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }