Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pipeline{
- environment{
- PACKAGE_VERSION = sh ( script: 'cat package.json | grep version | head -1 | awk -F: \'{ print $2 }\' | sed \'s/[\",]//g\' | tr -d \'[[:space:]]\'', returnStdout: true).trim()
- }
- agent any
- options {
- disableConcurrentBuilds()
- }
- stages{
- stage('Init'){
- steps{
- nvm('v10.10.0'){
- sh 'printenv'
- sh 'npm run clean'
- sh 'npm install'
- script {
- def versionValue = sh(returnStdout: true, script: "cat package.json | grep -o '\"version\":.*' | head -1").trim()
- def version = versionValue.split(/:/)[1].replaceAll("\"", "")
- def revisionValue = sh(returnStdout: true, script: "cat package.json | grep -o '\"revision\":.*'").trim()
- def revision = revisionValue.split(/:/)[1].replaceAll("\"", "")
- currentBuild.displayName = "${version} - ${revision}"
- }
- }
- }
- }
- /*
- stage('Build'){
- parallel {
- stage('Build NL'){
- steps{
- 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'
- }
- }
- stage('Build FR'){
- steps{
- 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'
- }
- }
- }
- }
- */
- stage('Translations'){
- steps{
- sh 'lokalise export --type xlf --unzip_to src/locale --export_all 1 --bundle_structure /%LANG_ISO%.%FORMAT%'
- sh 'lokalise export --type json --unzip_to src/locale/ngx-translate --export_all 1 --bundle_structure /%LANG_ISO%.%FORMAT%'
- 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'
- }
- }
- stage('Build FMSB'){
- steps{
- nvm('v10.10.0'){
- sh 'npm run init-fmsb'
- 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'
- 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'
- sh 'cd dist/fmsb && zip -FSr mutcare-${PACKAGE_VERSION}.zip *'
- }
- }
- }
- stage('Build LM'){
- when {
- anyOf {branch 'hotfix-*'; branch 'release-*'}
- }
- steps{
- nvm('v10.10.0'){
- sh 'npm run init-lm'
- 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'
- 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'
- sh 'cd dist/lm && zip -FSr mutcare-${PACKAGE_VERSION}.zip *'
- }
- }
- }
- /*
- stage('Unit Tests'){
- steps{
- sh 'npm run test'
- }
- }
- stage('Integration Tests'){
- steps{
- }
- }
- stage('Package'){
- when {
- anyOf { branch 'master'; branch 'develop' }
- }
- steps{
- sh 'npm run package'
- }
- }*/
- stage('Publish'){
- when {
- anyOf {branch 'hotfix-*'; branch 'release-*'}
- }
- steps{
- script{
- server = Artifactory.server 'artifactory'
- uploadSpec = """{
- "files": [
- {
- "pattern": "dist/fmsb/mutcare-${PACKAGE_VERSION}.zip",
- "target": "mutcare/be/fmsb/mutcare/${PACKAGE_VERSION}/"
- },
- {
- "pattern": "dist/lm/mutcare-${PACKAGE_VERSION}.zip",
- "target": "mutcare/be/lm/mutcare/${PACKAGE_VERSION}/"
- }
- ]
- }"""
- server.upload(uploadSpec)
- }
- }
- }
- stage('notifyAvailability') {
- when {
- anyOf {branch 'hotfix-*'; branch 'release-*'}
- }
- steps {
- echo "sending slack message to notify latest available build"
- }
- post {
- success {
- slackSend(channel: '#qa-test', message: "Latest Mutcare revision built successfully : ${currentBuild.displayName}")
- }
- }
- }
- stage('Deployment'){
- when {
- branch 'develop'
- }
- steps{
- script{
- sh "scp dist/fmsb/mutcare-${PACKAGE_VERSION}.zip mutcare@l306mci.fmsb.be:/home/mutcare/dists"
- sh "ssh mutcare@l306mci.fmsb.be ./mutcare-deploy.sh ${PACKAGE_VERSION}"
- }
- }
- }
- }
- post {
- failure{
- slackSend "Holy shit!! Build FAILED - ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} - ${env.BUILD_URL}"
- }
- fixed {
- slackSend color: "good", message: ":smile: Build back to normal- ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} - ${env.BUILD_URL}"
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement