Guest User

Untitled

a guest
May 20th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.16 KB | None | 0 0
  1. def call(body) {
  2. def pipelineParams = [:]
  3. body.resolveStrategy = Closure.DELEGATE_FIRST
  4. body.delegate = pipelineParams
  5. body()
  6.  
  7. pipeline {
  8. agent {
  9. label 'builder-backend'
  10. }
  11. options {
  12. disableConcurrentBuilds()
  13. skipStagesAfterUnstable()
  14. skipDefaultCheckout(true)
  15. buildDiscarder(logRotator(numToKeepStr: '10'))
  16. }
  17. stages {
  18. stage('build') {
  19. steps {
  20. notifyBitbucket('INPROGRESS', env.STAGE_NAME, env.STAGE_NAME)
  21. deleteDir()
  22. checkout scm
  23. sh """
  24. make ci-build
  25. """
  26. }
  27. post {
  28. success {
  29. notifySuccess(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  30. }
  31. failure {
  32. notifyFailure(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  33. }
  34. }
  35. }
  36. stage('qa: static code analysis') {
  37. steps {
  38. notifyBitbucket('INPROGRESS', env.STAGE_NAME, env.STAGE_NAME)
  39. sh """
  40. make ci-static-code-analysis
  41. """
  42. }
  43. post {
  44. success {
  45. notifySuccess(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  46. }
  47. failure {
  48. notifyFailure(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  49. }
  50. }
  51. }
  52. stage('qa: unit & integration tests') {
  53. steps {
  54. notifyBitbucket('INPROGRESS', env.STAGE_NAME, env.STAGE_NAME)
  55. sh """
  56. make ci-tests
  57. """
  58. }
  59. post {
  60. success {
  61. notifySuccess(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  62. }
  63. failure {
  64. notifyFailure(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  65. }
  66. }
  67. }
  68. stage('approval: dev') {
  69. agent none
  70. when {
  71. not {
  72. branch 'master'
  73. }
  74. }
  75. steps {
  76. script {
  77. timeout(5) {
  78. input "Deploy to dev?"
  79. }
  80. }
  81. }
  82. }
  83. stage('deploy: dev') {
  84. when {
  85. allOf {
  86. not {
  87. branch 'master'
  88. }
  89. expression { return currentBuild.result == null || currentBuild.result == 'SUCCESS' }
  90. }
  91. }
  92. steps {
  93. notifyBitbucket('INPROGRESS', env.STAGE_NAME, env.STAGE_NAME)
  94. releaseHeroku(pipelineParams.developmentRepositoryUrl, 'development')
  95. }
  96. post {
  97. success {
  98. notifySuccess(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  99. }
  100. failure {
  101. notifyFailure(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  102. }
  103. }
  104. }
  105. stage('deploy: stg') {
  106. when {
  107. allOf {
  108. branch 'master'
  109. expression { return currentBuild.result == null || currentBuild.result == 'SUCCESS' }
  110. }
  111. }
  112. steps {
  113. notifyBitbucket('INPROGRESS', env.STAGE_NAME, env.STAGE_NAME)
  114. releaseHeroku(pipelineParams.stagingRepositoryUrl, 'staging')
  115. }
  116. post {
  117. success {
  118. notifySuccess(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  119. }
  120. failure {
  121. notifyFailure(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  122. }
  123. }
  124. }
  125. stage('approval: prod') {
  126. agent none
  127. when {
  128. branch 'master'
  129. }
  130. steps {
  131. script {
  132. timeout(5) {
  133. input "Deploy to production?"
  134. }
  135. }
  136. }
  137. }
  138. stage('deploy: prod') {
  139. when {
  140. allOf {
  141. branch 'master'
  142. expression { return currentBuild.result == null || currentBuild.result == 'SUCCESS' }
  143. }
  144. }
  145. steps {
  146. notifyBitbucket('INPROGRESS', env.STAGE_NAME, env.STAGE_NAME)
  147. releaseHeroku(pipelineParams.productionRepositoryUrl, 'production')
  148. }
  149. post {
  150. success {
  151. notifySuccess(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  152. }
  153. failure {
  154. notifyFailure(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  155. }
  156. }
  157. }
  158. stage('publish api docs: prod') {
  159. when {
  160. allOf {
  161. branch 'master'
  162. expression { return currentBuild.result == null || currentBuild.result == 'SUCCESS' }
  163. }
  164. }
  165. steps {
  166. notifyBitbucket('INPROGRESS', env.STAGE_NAME, env.STAGE_NAME)
  167.  
  168. sh """
  169. make docs ${pipelineParams.swaggerYamlFilename}
  170. """
  171. }
  172. post {
  173. success {
  174. notifySuccess(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  175. }
  176. failure {
  177. notifyFailure(env.STAGE_NAME, pipelineParams.slackNotificationChannel)
  178. }
  179. }
  180. }
  181. }
  182. post {
  183. always {
  184. script {
  185. if (currentBuild.result == null) {
  186. currentBuild.result = 'SUCCESS'
  187. }
  188. }
  189. step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: gitAuthorEmail(), sendToIndividuals: true])
  190. }
  191. }
  192. }
  193. }
Add Comment
Please, Sign In to add comment