forked from inab/openEbench-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
95 lines (80 loc) · 3.56 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
pipeline {
agent any
stages {
stage('Install modules') {
steps {
// Install Modules
sh 'HOME=/home/jenkins npm install --no-save'
}
}
stage('Build') {
steps {
script{ // Check if prod folder exits if exits make a copy ro prod_old else create a prod folder
if(env.BRANCH_NAME == 'development'){
sh 'HOME=/home/jenkins PATH="${PWD}/node_modules/.bin:${PATH}" ng build --base-href /html/'
}
if(env.BRANCH_NAME == 'release1.0'){
sh 'HOME=/home/jenkins PATH="${PWD}/node_modules/.bin:${PATH}" ng build --prod --base-href /html/'
}
}
// Create dist folder
}
}
stage('Backup previous deployment') {
steps{
script{ // Check if prod folder exits if exits make a copy ro prod_old else create a prod folder
if(env.BRANCH_NAME == 'development'){
def folder = fileExists '/home/jenkins/prod'
if (folder) {
sh 'rm -R /home/jenkins/prod_old/*'
sh 'cp -R /home/jenkins/prod /home/jenkins/prod_old'
} else {
sh 'mkdir /home/jenkins/prod'
}
}
if(env.BRANCH_NAME == 'release1.0'){
def folder = fileExists '/gpfs_prod/html/prod'
if (folder) {
sh 'rm -R /gpfs_prod/html/prod_old/*'
sh 'cp -R /gpfs_prod/html/prod /gpfs_prod/html/prod_old'
} else {
sh 'mkdir /gpfs_prod/html/prod'
}
}
}
}
}
stage('Clean production files') {
steps {
script{
if(env.BRANCH_NAME == 'development'){
sh 'HOME=/home/jenkins rm -R /home/jenkins/prod/*'
}
if(env.BRANCH_NAME == 'release1.0'){
sh 'HOME=/home/jenkins rm -R /gpfs_prod/html/prod/*'
}
}
}
}
stage('Move Build to Production') {
steps {
script{
if(env.BRANCH_NAME == 'development'){
sh 'HOME=/home/jenkins cp -R ./dist/* /home/jenkins/prod'
}
if(env.BRANCH_NAME == 'release1.0'){
sh 'HOME=/home/jenkins cp -R ./dist/* /gpfs_prod/html/prod'
}
}
}
}
}
post {
success {
slackSend (color: '#00FF00', message: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
failure {
slackSend (color: '#FF0000', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}