-
Notifications
You must be signed in to change notification settings - Fork 7
/
Jenkinsfile
127 lines (102 loc) · 4 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env groovy
node('nimble-jenkins-slave') {
// -----------------------------------------------
// --------------- Staging Branch ----------------
// -----------------------------------------------
if (env.BRANCH_NAME == 'staging') {
stage('Clone and Update') {
git(url: 'https://github.com/nimble-platform/identity-service.git', branch: env.BRANCH_NAME)
sh 'git submodule init'
sh 'git submodule update'
}
stage('Run Tests') {
sh 'mvn clean test'
}
stage('Build Java') {
sh 'mvn clean install -DskipTests'
}
stage('Build Docker') {
sh 'mvn -f identity-service/pom.xml docker:build -DdockerImageTag=staging'
}
stage('Push Docker') {
sh 'docker push nimbleplatform/identity-service:staging'
}
stage('Deploy') {
sh 'ssh staging "cd /srv/nimble-staging/ && ./run-staging.sh restart-single identity-service"'
}
}
// -----------------------------------------------
// --------------- Staging V2 Branch ----------------
// -----------------------------------------------
if (env.BRANCH_NAME == 'staging-v2') {
stage('Clone and Update') {
git(url: 'https://github.com/nimble-platform/identity-service.git', branch: env.BRANCH_NAME)
sh 'git submodule init'
sh 'git submodule update'
}
stage('Run Tests') {
sh 'mvn clean test'
}
stage('Build Java') {
sh 'mvn clean install -DskipTests'
}
stage('Build Docker') {
sh 'mvn -f identity-service/pom.xml docker:build -DdockerImageTag=staging-v2'
}
stage('Push Docker') {
sh 'docker push nimbleplatform/identity-service:staging-v2'
}
stage('Deploy') {
sh 'ssh staging "cd /srv/nimble-staging/ && ./run-staging.sh restart-single identity-service-v2"'
}
}
// -----------------------------------------------
// ---------------- Master Branch ----------------
// -----------------------------------------------
if (env.BRANCH_NAME == 'master') {
stage('Clone and Update') {
git(url: 'https://github.com/nimble-platform/identity-service.git', branch: env.BRANCH_NAME)
sh 'git submodule init'
sh 'git submodule update'
}
stage('Run Tests') {
sh 'mvn clean test'
}
stage('Build Java') {
sh 'mvn clean install -DskipTests'
}
}
// -----------------------------------------------
// ---------------- Release Tags -----------------
// -----------------------------------------------
if( env.TAG_NAME ==~ /^\d+.\d+.\d+$/) {
stage('Clone and Update') {
git(url: 'https://github.com/nimble-platform/identity-service.git', branch: 'master')
sh 'git submodule init'
sh 'git submodule update'
}
stage('Set version') {
sh 'mvn org.codehaus.mojo:versions-maven-plugin:2.1:set -DnewVersion=' + env.TAG_NAME
sh 'mvn -f identity-service/pom.xml org.codehaus.mojo:versions-maven-plugin:2.1:set -DnewVersion=' + env.TAG_NAME
}
stage('Run Tests') {
sh 'mvn clean test'
}
stage('Build Java') {
sh 'mvn clean install -DskipTests'
}
stage('Build Docker') {
sh 'mvn -f identity-service/pom.xml docker:build'
}
stage('Push Docker') {
sh 'docker push nimbleplatform/identity-service:' + env.TAG_NAME
sh 'docker push nimbleplatform/identity-service:latest'
}
stage('Deploy MVP') {
sh 'ssh nimble "cd /data/deployment_setup/prod/ && sudo ./run-prod.sh restart-single identity-service"'
}
stage('Deploy Efactory') {
sh 'ssh efac-prod "cd /srv/nimble-efac/ && ./run-efac-prod.sh restart-single identity-service"'
}
}
}