Jenkinsfile-basic 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!groovy
  2. def statusHasChanged = false
  3. pipeline
  4. {
  5. agent none
  6. // Trigger the build
  7. triggers {
  8. // Poll gitlab explicitly every 15mn
  9. pollSCM('00-59/15 * * * *')
  10. }
  11. stages
  12. {
  13. stage('Tarball')
  14. {
  15. steps
  16. {
  17. node('autotools')
  18. {
  19. checkout scm
  20. sh 'contrib/ci.inria.fr/job-0-tarball.sh'
  21. script
  22. {
  23. env.tarballgz = sh (script: 'ls *.tar.gz', returnStdout: true).trim()
  24. }
  25. stash includes: "${env.tarballgz}", name: 'tarballgz'
  26. stash includes: "starpu.pdf", name: 'doc'
  27. // Stash those scripts because they are not in make dist
  28. dir('contrib/ci.inria.fr')
  29. {
  30. stash includes: "job-1-check.sh", name: 'script-unix-check'
  31. }
  32. archiveArtifacts artifacts: "${env.tarballgz},starpu.pdf", fingerprint: true, onlyIfSuccessful: true
  33. deleteDir()
  34. }
  35. }
  36. }
  37. stage('Check')
  38. {
  39. steps
  40. {
  41. script
  42. {
  43. labelToSelect = 'unix'
  44. listOfNodeNames = jenkins.model.Jenkins.instance.nodes.collect
  45. {
  46. node -> node.getLabelString().contains(labelToSelect) ? node.name : null
  47. }
  48. listOfNodeNames.removeAll(Collections.singleton(null))
  49. def p = listOfNodeNames.collectEntries
  50. {
  51. [ (it):
  52. {
  53. node(it)
  54. {
  55. dir('check-unix')
  56. {
  57. unstash 'tarballgz'
  58. unstash 'script-unix-check'
  59. sh 'chmod 755 job-1-check.sh && ./job-1-check.sh'
  60. deleteDir()
  61. }
  62. }
  63. }
  64. ]}
  65. parallel p;
  66. }
  67. }
  68. }
  69. }
  70. post
  71. {
  72. // hooks are called in order: always, changed, aborted, failure, success, unstable
  73. changed
  74. {
  75. echo "Build status has changed."
  76. script
  77. {
  78. statusHasChanged = true
  79. }
  80. }
  81. success
  82. {
  83. echo "Build success."
  84. // email when changed to success
  85. script
  86. {
  87. if (statusHasChanged)
  88. {
  89. emailext(body: '${DEFAULT_CONTENT}',
  90. subject: '${DEFAULT_SUBJECT}',
  91. replyTo: '$DEFAULT_REPLYTO',
  92. to: '$DEFAULT_RECIPIENTS',
  93. recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']])
  94. }
  95. }
  96. }
  97. failure
  98. {
  99. echo "Build failure."
  100. // always email on failure
  101. emailext(body: '${DEFAULT_CONTENT}',
  102. subject: '${DEFAULT_SUBJECT}',
  103. replyTo: '$DEFAULT_REPLYTO',
  104. to: '$DEFAULT_RECIPIENTS',
  105. recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']])
  106. }
  107. }
  108. }