forked from i-Asset/frontend-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
77 lines (58 loc) · 2.52 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
node('robxtask-jenkins-slave') {
// -----------------------------------------------
// --------------- Staging Branch ----------------
// -----------------------------------------------
if (env.BRANCH_NAME == 'staging') {
stage('Clone and Update') {
git(url: 'https://github.com/ROBxTASK/frontend-service.git', branch: env.BRANCH_NAME)
}
stage('Build Application - staging') {
sh 'mvn clean install -Denv=staging'
}
stage('Build Docker - staging') {
sh 'docker build -t robxtask/frontend-service:staging ./target'
}
stage('Push Docker - staging') {
sh 'docker push robxtask/frontend-service:staging'
}
stage('Deploy - staging') {
sh 'ssh staging "cd /srv/docker-setup/staging/ && ./run-staging.sh restart-single frontend-service"'
}
}
// -----------------------------------------------
// ---------------- Master Branch ----------------
// -----------------------------------------------
if (env.BRANCH_NAME == 'master') {
stage('Clone and Update') {
git(url: 'https://github.com/ROBxTASK/frontend-service.git', branch: env.BRANCH_NAME)
}
stage('Build Application') {
sh 'mvn clean install -Denv=prod'
}
}
// -----------------------------------------------
// ---------------- Release Tags -----------------
// -----------------------------------------------
if( env.TAG_NAME ==~ /^\d+.\d+.\d+$/) {
stage('Clone and Update') {
git(url: 'https://github.com/ROBxTASK/frontend-service.git', branch: 'master')
}
stage('Set version') {
sh 'mvn versions:set -DnewVersion=' + env.TAG_NAME
}
stage('Build Application - ' + env.TAG_NAME) {
sh 'mvn clean install -Denv=prod'
}
stage('Build Docker - ' + env.TAG_NAME) {
sh 'docker build -t robxtask/frontend-service ./target'
}
stage('Push Docker - ' + env.TAG_NAME) {
sh 'docker push robxtask/frontend-service:latest'
sh 'docker tag robxtask/frontend-service:latest robxtask/frontend-service:' + env.TAG_NAME
sh 'docker push robxtask/frontend-service:' + env.TAG_NAME
}
stage('Deploy - ' + env.TAG_NAME) {
// FIXME: sh 'ssh robxtask "cd /data/deployment_setup/prod/ && export COMPOSE_HTTP_TIMEOUT=600 && sudo ./run-prod.sh restart-single frontend-service"'
}
}
}