forked from hadithhouse/HadithHouseWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
112 lines (99 loc) · 2.36 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env groovy
pipeline {
agent any
triggers {
issueCommentTrigger('.*test this please.*')
}
stages {
stage('Install Node modules') {
steps {
sh('npm install')
}
}
stage('Lint') {
steps {
sh('npm run lint')
}
}
stage('Test') {
steps {
sh('npm run test')
}
}
stage('Build Dev') {
steps {
sh('npm run build-dev')
}
}
stage('Deploy Dev') {
when {
// Deploy only when the branch being built is master.
expression { env.BRANCH_NAME == 'master' }
}
steps {
echo('Archive folder')
sh('zip -qr /tmp/HadithHouseWeb.zip dist/ scripts/')
echo('Copy the archive to dev.hadithhouse.net for deployment')
sh('''scp /tmp/HadithHouseWeb.zip deployer@dev.hadithhouse.net:/tmp/HadithHouseWeb.zip
rm /tmp/HadithHouseWeb.zip
''')
echo ('Unzip the archive and start the deployment.')
sh('''ssh deployer@dev.hadithhouse.net << "EOF"
cd /tmp
rm -rf HadithHouseWeb
mkdir HadithHouseWeb
unzip -qo /tmp/HadithHouseWeb.zip -d HadithHouseWeb
cd HadithHouseWeb
chmod u+x scripts/deploy.sh
./scripts/deploy.sh
deploy_exit_code=$?
cd ..
rm -rf HadithHouseWeb
exit $deploy_exit_code
EOF
exit $?
''')
}
}
stage('Build Prod') {
when {
// Deploy only when the branch being built is master.
expression { env.BRANCH_NAME == 'master' }
}
steps {
sh('rm -rf dist/')
sh('npm run build')
}
}
stage('Deploy Prod') {
when {
// Deploy only when the branch being built is master.
expression { env.BRANCH_NAME == 'master' }
}
steps {
echo('Archive folder')
sh('zip -qr /tmp/HadithHouseWeb.zip dist/ scripts/')
echo('Copy the archive to www.hadithhouse.net for deployment')
sh('''scp /tmp/HadithHouseWeb.zip deployer@www.hadithhouse.net:/tmp/HadithHouseWeb.zip
rm /tmp/HadithHouseWeb.zip
''')
echo ('Unzip the archive and start the deployment.')
sh('''ssh deployer@www.hadithhouse.net << "EOF"
cd /tmp
rm -rf HadithHouseWeb
mkdir HadithHouseWeb
unzip -qo /tmp/HadithHouseWeb.zip -d HadithHouseWeb
cd HadithHouseWeb
chmod u+x scripts/deploy.sh
./scripts/deploy.sh
deploy_exit_code=$?
cd ..
rm -rf HadithHouseWeb
exit $deploy_exit_code
EOF
exit $?
''')
}
}
}
}