-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
206 lines (188 loc) · 6.83 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
pipeline {
agent {
node {
label 'py-uniformes'
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '5', artifactNumToKeepStr: '5'))
disableConcurrentBuilds()
skipDefaultCheckout()
}
stages {
stage('CheckOut') {
steps {
checkout scm
}
}
stage('Analise codigo') {
when {
branch 'homolog'
}
steps {
sh 'sonar-scanner \
-Dsonar.projectKey=SME-PTRF-BackEnd \
-Dsonar.sources=. \
-Dsonar.host.url=http://sonar.sme.prefeitura.sp.gov.br \
-Dsonar.login=0091e06f1e1b2888df54e200dc9403b1aa6b8280'
}
}
stage('Deploy DEV') {
when {
branch 'develop'
}
steps {
sh 'echo build docker image desenvolvimento'
// Start JOB para build das imagens Docker e push SME Registry
script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,
jobId: "65b10cf4-0216-4fc8-9f1d-bcd0615f767e",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}
//Start JOB de deploy Kubernetes
sh 'echo Deploy ambiente desenvolvimento'
script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,
jobId: "f5cd9659-9b76-437f-87cc-fcd164bcdd21",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}
}
}
stage('Deploy homologacao') {
when {
branch 'homolog'
}
steps {
timeout(time: 24, unit: "HOURS") {
// telegramSend("${JOB_NAME}...O Build ${BUILD_DISPLAY_NAME} - Requer uma aprovação para deploy !!!\n Consulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)\n")
input message: 'Deseja realizar o deploy?', ok: 'SIM', submitter: 'ebufaino, marcos_nastri, calvin_rossinhole, ollyver_ottoboni, kelwy_oliveira, alessandro_fernandes, anderson_morais'
}
sh 'echo Deploying ambiente homologacao'
// Start JOB para build das imagens Docker e push SME Registry
script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,
//JOB DE BUILD
jobId: "db872f07-299e-49c5-a5d5-d3a6d653c252",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}
//Start JOB deploy Kubernetes
script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,
jobId: "3b7b83c8-71f4-4611-ac34-591db68ea35e",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}
}
}
stage('Deploy PROD') {
when {
branch 'master'
}
steps {
timeout(time: 24, unit: "HOURS") {
// telegramSend("${JOB_NAME}...O Build ${BUILD_DISPLAY_NAME} - Requer uma aprovação para deploy !!!\n Consulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)\n")
input message: 'Deseja realizar o deploy?', ok: 'SIM', submitter: 'ebufaino, marcos_nastri, calvin_rossinhole, ollyver_ottoboni, kelwy_oliveira, alessandro_fernandes, anderson_morais'
}
sh 'echo Build image docker Produção'
// Start JOB para build das imagens Docker e push SME Registry
script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,
//JOB DE BUILD
jobId: "59460a81-6dc7-443f-b95e-c45d1904c7bf",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}
//Start JOB deploy kubernetes
script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,
jobId: "9e332308-df1a-4095-b46f-6b579906e315",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}
}
}
}
post {
always {
echo 'One way or another, I have finished'
}
success {
telegramSend("${JOB_NAME}...O Build ${BUILD_DISPLAY_NAME} - Esta ok !!!\n Consulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)\n\n Uma nova versão da aplicação esta disponivel!!!")
}
unstable {
telegramSend("O Build ${BUILD_DISPLAY_NAME} <${env.BUILD_URL}> - Esta instavel ...\nConsulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)")
}
failure {
telegramSend("${JOB_NAME}...O Build ${BUILD_DISPLAY_NAME} - Quebrou. \nConsulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)")
}
changed {
echo 'Things were different before...'
}
aborted {
telegramSend("O Build ${BUILD_DISPLAY_NAME} - Foi abortado.\nConsulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)")
}
}
}