Jenkinsfile-basic 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. deleteDir()
  29. }
  30. }
  31. }
  32. stage('Check')
  33. {
  34. steps
  35. {
  36. script
  37. {
  38. labelToSelect = 'unix'
  39. listOfNodeNames = jenkins.model.Jenkins.instance.nodes.collect
  40. {
  41. node -> node.getLabelString().contains(labelToSelect) ? node.name : null
  42. }
  43. listOfNodeNames.removeAll(Collections.singleton(null))
  44. def p = listOfNodeNames.collectEntries
  45. {
  46. [ (it):
  47. {
  48. node(it)
  49. {
  50. dir('check-unix')
  51. {
  52. unstash 'tarballgz'
  53. unstash 'script-unix-check'
  54. sh 'chmod 755 job-1-check.sh && ./job-1-check.sh'
  55. deleteDir()
  56. }
  57. }
  58. }
  59. ]}
  60. parallel p;
  61. }
  62. }
  63. }
  64. }
  65. post
  66. {
  67. // hooks are called in order: always, changed, aborted, failure, success, unstable
  68. changed
  69. {
  70. echo "Build status has changed."
  71. script
  72. {
  73. statusHasChanged = true
  74. }
  75. }
  76. success
  77. {
  78. echo "Build success."
  79. // email when changed to success
  80. script
  81. {
  82. if (statusHasChanged)
  83. {
  84. emailext(body: '${DEFAULT_CONTENT}',
  85. subject: '${DEFAULT_SUBJECT}',
  86. replyTo: '$DEFAULT_REPLYTO',
  87. to: '$DEFAULT_RECIPIENTS',
  88. recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']])
  89. }
  90. }
  91. }
  92. failure
  93. {
  94. echo "Build failure."
  95. // always email on failure
  96. emailext(body: '${DEFAULT_CONTENT}',
  97. subject: '${DEFAULT_SUBJECT}',
  98. replyTo: '$DEFAULT_REPLYTO',
  99. to: '$DEFAULT_RECIPIENTS',
  100. recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']])
  101. }
  102. }
  103. }