Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. pipeline{
  2. environment{
  3. PACKAGE_VERSION = sh ( script: 'cat package.json | grep version | head -1 | awk -F: \'{ print $2 }\' | sed \'s/[\",]//g\' | tr -d \'[[:space:]]\'', returnStdout: true).trim()
  4. }
  5. agent any
  6.  
  7. options {
  8. disableConcurrentBuilds()
  9. }
  10.  
  11. stages{
  12.  
  13. stage('Init'){
  14. steps{
  15. nvm('v10.10.0'){
  16. sh 'printenv'
  17. sh 'npm run clean'
  18. sh 'npm install'
  19.  
  20. script {
  21. def versionValue = sh(returnStdout: true, script: "cat package.json | grep -o '\"version\":.*' | head -1").trim()
  22. def version = versionValue.split(/:/)[1].replaceAll("\"", "")
  23. def revisionValue = sh(returnStdout: true, script: "cat package.json | grep -o '\"revision\":.*'").trim()
  24. def revision = revisionValue.split(/:/)[1].replaceAll("\"", "")
  25. currentBuild.displayName = "${version} - ${revision}"
  26. }
  27. }
  28. }
  29. }
  30.  
  31. /*
  32. stage('Build'){
  33. parallel {
  34. stage('Build NL'){
  35. steps{
  36. sh 'ng build --i18nFile=src/locale/nl_BE.xlf --i18nFormat=xlf --locale=nl --aot --missing-translation=warning --output-path=dist/nl --base-href=/nl/ --deploy-url=/nl/ --output-hashing=all --env=prod'
  37. }
  38. }
  39. stage('Build FR'){
  40. steps{
  41. sh 'ng build --i18nFile=src/locale/fr_BE.xlf --i18nFormat=xlf --locale=fr --aot --missing-translation=warning --output-path=dist/fr --base-href=/fr/ --deploy-url=/fr/ --output-hashing=all --env=prod'
  42. }
  43. }
  44. }
  45. }
  46. */
  47.  
  48. stage('Translations'){
  49. steps{
  50. sh 'lokalise export --type xlf --unzip_to src/locale --export_all 1 --bundle_structure /%LANG_ISO%.%FORMAT%'
  51. sh 'lokalise export --type json --unzip_to src/locale/ngx-translate --export_all 1 --bundle_structure /%LANG_ISO%.%FORMAT%'
  52. sh 'mv -f src/locale/ngx-translate/fr_BE.json src/locale/ngx-translate/fr.json && mv -f src/locale/ngx-translate/nl_BE.json src/locale/ngx-translate/nl.json'
  53. }
  54. }
  55.  
  56. stage('Build FMSB'){
  57. steps{
  58. nvm('v10.10.0'){
  59. sh 'npm run init-fmsb'
  60. sh 'ng build --i18nFile=src/locale/nl_BE.xlf --i18nFormat=xlf --locale=nl --aot --missing-translation=warning --output-path=dist/fmsb/nl --output-hashing=all --env=prod'
  61. sh 'ng build --i18nFile=src/locale/fr_BE.xlf --i18nFormat=xlf --locale=fr --aot --missing-translation=warning --output-path=dist/fmsb/fr --output-hashing=all --env=prod'
  62. sh 'cd dist/fmsb && zip -FSr mutcare-${PACKAGE_VERSION}.zip *'
  63. }
  64. }
  65. }
  66.  
  67. stage('Build LM'){
  68. when {
  69. anyOf {branch 'hotfix-*'; branch 'release-*'}
  70. }
  71. steps{
  72. nvm('v10.10.0'){
  73. sh 'npm run init-lm'
  74. sh 'ng build --i18nFile=src/locale/nl_BE.xlf --i18nFormat=xlf --locale=nl --aot --missing-translation=warning --output-path=dist/lm/nl --output-hashing=all --env=prod'
  75. sh 'ng build --i18nFile=src/locale/fr_BE.xlf --i18nFormat=xlf --locale=fr --aot --missing-translation=warning --output-path=dist/lm/fr --output-hashing=all --env=prod'
  76. sh 'cd dist/lm && zip -FSr mutcare-${PACKAGE_VERSION}.zip *'
  77. }
  78. }
  79. }
  80.  
  81. /*
  82. stage('Unit Tests'){
  83. steps{
  84. sh 'npm run test'
  85. }
  86. }
  87.  
  88.  
  89. stage('Integration Tests'){
  90.  
  91. steps{
  92.  
  93. }
  94.  
  95. }
  96.  
  97. stage('Package'){
  98. when {
  99. anyOf { branch 'master'; branch 'develop' }
  100. }
  101. steps{
  102. sh 'npm run package'
  103. }
  104. }*/
  105.  
  106.  
  107. stage('Publish'){
  108. when {
  109. anyOf {branch 'hotfix-*'; branch 'release-*'}
  110. }
  111. steps{
  112. script{
  113. server = Artifactory.server 'artifactory'
  114. uploadSpec = """{
  115. "files": [
  116. {
  117. "pattern": "dist/fmsb/mutcare-${PACKAGE_VERSION}.zip",
  118. "target": "mutcare/be/fmsb/mutcare/${PACKAGE_VERSION}/"
  119. },
  120. {
  121. "pattern": "dist/lm/mutcare-${PACKAGE_VERSION}.zip",
  122. "target": "mutcare/be/lm/mutcare/${PACKAGE_VERSION}/"
  123. }
  124. ]
  125. }"""
  126. server.upload(uploadSpec)
  127. }
  128. }
  129. }
  130.  
  131. stage('notifyAvailability') {
  132. when {
  133. anyOf {branch 'hotfix-*'; branch 'release-*'}
  134. }
  135. steps {
  136. echo "sending slack message to notify latest available build"
  137. }
  138. post {
  139. success {
  140. slackSend(channel: '#qa-test', message: "Latest Mutcare revision built successfully : ${currentBuild.displayName}")
  141. }
  142. }
  143. }
  144.  
  145. stage('Deployment'){
  146. when {
  147. branch 'develop'
  148. }
  149. steps{
  150. script{
  151. sh "scp dist/fmsb/mutcare-${PACKAGE_VERSION}.zip mutcare@l306mci.fmsb.be:/home/mutcare/dists"
  152. sh "ssh mutcare@l306mci.fmsb.be ./mutcare-deploy.sh ${PACKAGE_VERSION}"
  153. }
  154. }
  155. }
  156. }
  157.  
  158. post {
  159. failure{
  160. slackSend "Holy shit!! Build FAILED - ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} - ${env.BUILD_URL}"
  161. }
  162. fixed {
  163. slackSend color: "good", message: ":smile: Build back to normal- ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} - ${env.BUILD_URL}"
  164. }
  165. }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement