Jenkinsfile 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. // Autogenerated by build scripts. Do not edit.
  2. pipeline {
  3. agent {
  4. node {
  5. label 'jenkins-agent-web'
  6. customWorkspace '/workspace'
  7. }
  8. }
  9. options {
  10. timestamps()
  11. timeout(time: 15, unit: 'MINUTES')
  12. }
  13. environment {
  14. BRANCH_NAME = "${env.CHANGE_BRANCH ? env.CHANGE_BRANCH : env.BRANCH_NAME}"
  15. JENKINS_BUILD_NUMBER = "${BUILD_NUMBER}"
  16. DOCKER_COMPOSE_FLAGS = '-f docker-compose.ci.yml'
  17. }
  18. stages {
  19. stage('Set Build Variables') {
  20. steps {
  21. script {
  22. def relevantCommitHash
  23. if (env.CHANGE_BRANCH) {
  24. def commitExistsOnRemote = sh(script: "git branch --remotes --contains ${GIT_COMMIT}", returnStdout: true).trim()
  25. if (commitExistsOnRemote) {
  26. echo "PR build detected, but commit exists on remote. Using ${GIT_COMMIT}"
  27. relevantCommitHash = "${GIT_COMMIT}"
  28. } else {
  29. def parentCommits = sh(script: 'git rev-parse HEAD^@', returnStdout: true).trim().split('\n')
  30. if (parentCommits.size() >= 2) {
  31. echo "PR build detected. Jenkins checked out a merge commit: ${GIT_COMMIT} (parents: ${parentCommits.join(', ')})"
  32. relevantCommitHash = parentCommits[0]
  33. echo "Using first parent (branch commit): ${relevantCommitHash}"
  34. } else {
  35. echo "WARN: PR build detected, but ${GIT_COMMIT} is neither a merge commit, nor does it exist on the remote."
  36. relevantCommitHash = "${GIT_COMMIT}"
  37. }
  38. }
  39. } else {
  40. echo "Branch build detected. Using commit: ${GIT_COMMIT}"
  41. relevantCommitHash = "${GIT_COMMIT}"
  42. }
  43. env.COMMIT_SHA = relevantCommitHash
  44. env.SHORT_SHA = relevantCommitHash.take(7)
  45. env.BUILD_NUMBER = "${env.SHORT_SHA}_${env.JENKINS_BUILD_NUMBER}"
  46. }
  47. }
  48. }
  49. stage('Stage 1') {
  50. parallel {
  51. stage('Build') {
  52. steps {
  53. dir('services/filestore') {
  54. retry(count: 3) {
  55. sh 'make build'
  56. }
  57. }
  58. }
  59. }
  60. stage('Create reports folder') {
  61. steps {
  62. sh 'mkdir services/filestore/reports'
  63. }
  64. }
  65. }
  66. }
  67. stage('Stage 2') {
  68. parallel {
  69. stage('Push Branch Image') {
  70. steps {
  71. dir('services/filestore') {
  72. sh 'make push_branch'
  73. }
  74. }
  75. }
  76. stage('Shellcheck') {
  77. steps {
  78. dir('services/filestore') {
  79. sh 'make shellcheck'
  80. }
  81. }
  82. }
  83. stage('Lint') {
  84. steps {
  85. dir('services/filestore') {
  86. sh 'make lint_ci'
  87. }
  88. }
  89. post {
  90. always {
  91. recordIssues checksAnnotationScope: 'ALL', enabledForFailure: true, failOnError: true, id: 'filestore-eslint', name: 'filestore eslint', qualityGates: [[integerThreshold: 1, threshold: 1.0, type: 'TOTAL']], sourceCodeRetention: 'LAST_BUILD', tools: [esLint(pattern: 'services/filestore/reports/eslint.json')]
  92. }
  93. }
  94. }
  95. stage('Format') {
  96. steps {
  97. dir('services/filestore') {
  98. sh 'make format_ci'
  99. }
  100. }
  101. }
  102. stage('Typecheck') {
  103. steps {
  104. dir('services/filestore') {
  105. sh 'make typecheck_ci'
  106. }
  107. }
  108. }
  109. stage('Test Unit') {
  110. steps {
  111. dir('services/filestore') {
  112. retry(count: 3) {
  113. sh 'make test_unit'
  114. }
  115. }
  116. }
  117. }
  118. stage('Test Acceptance SHARD_01_') {
  119. environment {
  120. COMPOSE_PROJECT_NAME_TEST_ACCEPTANCE = "test_acceptance_shard_01_x"
  121. MOCHA_GREP = "SHARD_01_"
  122. }
  123. steps {
  124. dir('services/filestore') {
  125. retry(count: 3) {
  126. sh 'make test_acceptance'
  127. }
  128. }
  129. }
  130. }
  131. stage('Test Acceptance SHARD_02_') {
  132. environment {
  133. COMPOSE_PROJECT_NAME_TEST_ACCEPTANCE = "test_acceptance_shard_02_x"
  134. MOCHA_GREP = "SHARD_02_"
  135. }
  136. steps {
  137. dir('services/filestore') {
  138. retry(count: 3) {
  139. sh 'make test_acceptance'
  140. }
  141. }
  142. }
  143. }
  144. stage('Test Acceptance SHARD_03_') {
  145. environment {
  146. COMPOSE_PROJECT_NAME_TEST_ACCEPTANCE = "test_acceptance_shard_03_x"
  147. MOCHA_GREP = "SHARD_03_"
  148. }
  149. steps {
  150. dir('services/filestore') {
  151. retry(count: 3) {
  152. sh 'make test_acceptance'
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. stage('Push Production') {
  160. steps {
  161. dir('services/filestore') {
  162. sh 'make push'
  163. }
  164. }
  165. }
  166. }
  167. post {
  168. always {
  169. junit checksName: 'filestore test results', testResults: 'services/filestore/reports/junit-*.xml'
  170. }
  171. cleanup {
  172. dir('services/filestore') {
  173. sh 'make clean'
  174. }
  175. sh 'make clean_jenkins -j10'
  176. }
  177. }
  178. }