-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
82 lines (81 loc) · 1.9 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
pipeline {
agent any
stages {
stage('Check dependencies') {
agent {
docker {
image 'node:8'
}
}
steps {
sh 'npm install'
echo 'Everything is okay, we can continue !'
}
}
stage('Build') {
parallel {
stage('Build dev') {
when {
branch "dev"
}
steps {
sh 'docker build -t nip/front-dev .'
echo 'Docker dev image built'
}
}
stage('Build prod') {
when {
branch "master"
}
steps {
sh 'docker build -t nip/front --build-arg SSL_FULLCHAIN="$(cat /srv/certs/fullchain.pem)" --build-arg SSL_PRIVKEY="$(cat /srv/certs/privkey.pem)" .'
echo 'Docker prod image built'
}
}
stage('Stop old dev') {
when {
branch "dev"
}
steps {
sh 'docker stop nip-front-dev || true'
sh 'docker rm nip-front-dev || true'
sh 'docker rmi nip/front-dev || true'
echo 'Old dev container stopped'
}
}
stage('Stop old prod') {
when {
branch "master"
}
steps {
sh 'docker stop nip-front || true'
sh 'docker rm nip-front || true'
sh 'docker rmi nip/front || true'
echo 'Old prod container stopped'
}
}
}
}
stage('Run dev container') {
when {
branch "dev"
}
steps {
sh 'docker run -p 4200:4200 -d --name nip-front-dev nip/front-dev'
echo 'Dev container ready !'
}
}
stage('Run prod container') {
when {
branch "master"
}
steps {
sh 'docker run -p 443:4200 -d --name nip-front nip/front'
echo 'Prod container ready !'
}
}
}
environment {
HOME = '.'
}
}