Jenkinsfile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. pipeline {
  2. agent {
  3. node {
  4. label 'jenkins-agent-web'
  5. customWorkspace '/workspace'
  6. }
  7. }
  8. options {
  9. timestamps()
  10. parallelsAlwaysFailFast()
  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. BUILD_NUMBER = "${SHORT_SHA}_${BUILD_NUMBER}"
  17. COMMIT_SHA = "${GIT_COMMIT}"
  18. SHORT_SHA = "${GIT_COMMIT.take(7)}"
  19. }
  20. stages {
  21. stage('Stage 1') {
  22. parallel {
  23. stage('Build') {
  24. steps {
  25. dir('services/git-bridge') {
  26. sh 'make docker_build_base'
  27. }
  28. }
  29. }
  30. stage('Install monorepo') {
  31. steps {
  32. sh 'make monorepo_setup'
  33. }
  34. }
  35. }
  36. }
  37. stage('Stage 2') {
  38. parallel {
  39. stage('Build production and push') {
  40. steps {
  41. dir('services/git-bridge') {
  42. sh 'make docker_build'
  43. sh 'make push_branch'
  44. }
  45. }
  46. }
  47. stage('Format Java') {
  48. steps {
  49. dir('services/git-bridge') {
  50. sh 'make docker_format'
  51. }
  52. }
  53. }
  54. stage('Format Jenkinsfile') {
  55. steps {
  56. sh 'bin/run monorepo npm run format:jenkins'
  57. }
  58. }
  59. stage('Test') {
  60. steps {
  61. dir('services/git-bridge') {
  62. sh 'make docker_test'
  63. }
  64. }
  65. }
  66. }
  67. }
  68. stage('Push Production') {
  69. steps {
  70. dir('services/git-bridge') {
  71. sh 'make push'
  72. }
  73. }
  74. }
  75. }
  76. post {
  77. // Collect junit test results for both success and failure case.
  78. always {
  79. junit checksName: 'git-bridge test results', testResults: 'services/git-bridge/target/surefire-reports/*.xml'
  80. }
  81. cleanup {
  82. dir('services/git-bridge') {
  83. sh 'make clean_ci'
  84. }
  85. sh 'make clean_jenkins'
  86. }
  87. }
  88. }