Jenkinsfile-basic 2.2 KB

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