forked from bbachi/docker-multibuild-example
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJenkinsfile
More file actions
80 lines (55 loc) · 1.63 KB
/
Jenkinsfile
File metadata and controls
80 lines (55 loc) · 1.63 KB
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
#!groovy
node('server') {
currentBuild.result = "SUCCESS"
try {
stage('Checkout'){
checkout scm
}
stage('Test'){
env.NODE_ENV = "test"
print "Environment will be : ${env.NODE_ENV}"
sh 'node -v'
sh 'npm prune'
sh 'npm install'
sh 'npm test'
}
stage('Build Docker'){
sh 'docker build -t sangwan70/bulletinboard:v1 .'
/*
sh './dockerbuild.sh'
*/
}
stage('Deploy'){
echo 'Push to Repo'
/*
sh './dockerPushToRepo.sh'
*/
echo 'ssh to web server and tell it to pull new image'
sh 'docker run --name bb -d sangwan70/bulletinboard:v1'
sh 'sudo firewall-cmd --permanent --add-port=3070/tcp'
sh 'sudo firewall-cmd --reload'
/*
sh 'ssh deploy@tester1.example.com running/xxxxxxx/dockerRun.sh'
*/
}
stage('Cleanup'){
echo 'prune and cleanup'
sh 'npm prune'
sh 'rm node_modules -rf'
mail body: 'project build successful',
from: 'xxxx@yyyyy.com',
replyTo: 'xxxx@yyyy.com',
subject: 'project build successful',
to: 'yyyyy@yyyy.com'
}
}
catch (err) {
currentBuild.result = "FAILURE"
mail body: "project build error is here: ${env.BUILD_URL}" ,
from: 'xxxx@yyyy.com',
replyTo: 'yyyy@yyyy.com',
subject: 'project build failed',
to: 'zzzz@yyyyy.com'
throw err
}
}