This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathJenkinsfile
147 lines (128 loc) · 3.34 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
def mainBranch = false
pipeline {
agent any
environment {
PATH = "/opt/gradle/gradle-6.3/bin:$PATH"
SLACK_CHANNEL = '#jenkins-notification'
}
stages {
stage('Git Checkout') {
steps {
checkout scm
echo 'Git Checkout Success!'
}
}
stage('Test') {
steps {
sh 'gradle test'
echo 'test success'
}
/* post {
failure {
slackSend (channel: SLACK_CHANNEL, color: '#F01717', message: "Test Failed '[${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
} */
}
stage('Build') {
steps {
sh 'gradle clean build --exclude-task test --exclude-task asciidoctor'
echo 'build success'
}
/* post {
success {
slackSend (channel: SLACK_CHANNEL, color: '#00FF00', message: "Successful testing and build '[${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
failure {
slackSend (channel: SLACK_CHANNEL, color: '#F01717', message: "Build Failed '[${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
} */
}
stage('Check Branch') {
when {
branch 'develop'
}
steps {
script {
mainBranch = true
}
}
}
stage('Idle Port Stop') {
when {
expression {
mainBranch
}
}
steps([$class: 'BapSshPromotionPublisherPlugin']) {
sshPublisher(
continueOnError: false, failOnError: true,
publishers: [
sshPublisherDesc(
configName: "shoe-auction-reverse-proxy",
verbose: true,
transfers: [
sshTransfer(
execCommand: "sh /root/.scripts/stop.sh"
)
]
)
]
)
}
}
stage('Deploy To Idle Port') {
when {
expression {
mainBranch
}
}
steps([$class: 'BapSshPromotionPublisherPlugin']) {
sshPublisher(
continueOnError: false, failOnError: true,
publishers: [
sshPublisherDesc(
configName: "shoe-auction-reverse-proxy",
verbose: true,
transfers: [
sshTransfer(
execCommand: "sh /root/.scripts/start.sh"
)
]
)
]
)
}
}
stage('Check Health And Switch Ports') {
when {
expression {
mainBranch
}
}
steps([$class: 'BapSshPromotionPublisherPlugin']) {
sshPublisher(
continueOnError: false, failOnError: true,
publishers: [
sshPublisherDesc(
configName: "shoe-auction-reverse-proxy",
verbose: true,
transfers: [
sshTransfer(
execCommand: "sh /root/.scripts/health.sh"
)
]
)
]
)
}
/* post {
success {
slackSend (channel: SLACK_CHANNEL, color: '#00FF00', message: "Health check and deployment successful '[${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
failure {
slackSend (channel: SLACK_CHANNEL, color: '#F01717', message: "Health check and deployment failure '[${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
} */
}
}
}