-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
221 lines (203 loc) · 7.22 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/usr/bin/env groovy
@Library('cplib@release/2.0.0') _
import com.bcbsfl.paas.cplib.helpers.Build
import com.bcbsfl.paas.cplib.helpers.Workspace
import com.bcbsfl.paas.cplib.utils.Openshift
def bld = new Build()
def wspace = new Workspace()
def osh = new Openshift()
def gradleTasks = "clean compileJava build"
def projectName = "netflix-conductor"
def appName = "conductor-es-reconciliation"
def checkoutAppOcpConfigBranch = "master"
def appReleaseTag = "${BUILD_NUMBER}"
pipeline {
agent any
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '30', daysToKeepStr: '15'))
skipDefaultCheckout(true)
timestamps()
skipStagesAfterUnstable()
}
parameters {
string (
name : 'RELEASE_VERSION',
defaultValue: '',
description: '[Optional] Application Docker release tag (e.g. master, 1.0.0, 1.0.0.15). Please use this if you need to deploy an earlier version of the code that is already built (No build will be done in this case).'
)
booleanParam (
name: 'UNIT_DEPLOY',
defaultValue: true,
description: 'Please check this if you want to deploy to the Unit (netflix-conductor-unit namespace) environment.'
)
booleanParam (
name: 'TEST_DEPLOY',
defaultValue: false,
description: 'Please check this if you want to deploy to the Test (netflix-conductor-test namespace) environment.'
)
booleanParam (
name: 'STAGE_DEPLOY',
defaultValue: false,
description: 'Please check this if you want to deploy to the Stage (netflix-conductor--stage namespace) environment.'
)
booleanParam(
name: 'PROD',
defaultValue: false,
description: 'Boolean Flag for PROD deploy: [true] - Run PROD stages [false] - Skip PROD stages'
)
string(
name: 'NOTIFICATION',
defaultValue: 'some.one@bcbsfl.com',
description: 'Comma-delimited list of recipients to receive Approval Notifications'
)
string(
name: 'TICKET',
defaultValue: '',
description: 'Remedy Task (TAS)'
)
}
stages {
stage('Prepare') {
steps {
script {
log.info "******************* AFTER BUILD, DEPLOYING TO THESE ENVIRONMENTS *********************"
if(params.UNIT_DEPLOY == true) {
log.info("Unit")
}
if(params.TEST_DEPLOY == true) {
log.info("Test")
}
if(params.STAGE_DEPLOY == true) {
log.info("Stage")
}
if(params.PROD == true) {
log.info("Prod")
}
log.info "**************************************************************************************"
log.info "Explicit scm checkout ..."
checkout scm
wspace.init()
// wspace.checkoutAppOcpConfig(appName, checkoutAppOcpConfigBranch)
log.info "after checkout..."
appReleaseTag = wspace.getBuildProperty("version") + "." + env.BUILD_NUMBER
}
}
}
stage('Build Artifacts') {
steps {
script {
bld.gradle("gradle-5.2.1", gradleTasks + " --refresh-dependencies")
log.info "Preparing Image contents ..."
tmp_dir = "tmp"
deployments_dir = tmp_dir
log.info "Copy necessary build artifacts into the deployments dir ..."
sh """
ls -lt .
ls -lt ./build
mkdir -p ${deployments_dir}
find build -name "*.jar" -exec sh -c 'cp "\$@" "\$0"' ${deployments_dir} {} +
mv ${deployments_dir}/*.jar ${deployments_dir}/${appName}.jar
chmod -R 777 ${tmp_dir}
# Archive Build
tar -cjf ${appName}.tar -C ${tmp_dir} .
"""
log.info "Displaying artifacts ..."
sh "ls -lt ${deployments_dir}"
}
}
}
stage('Build Image') {
steps {
script {
if(!wspace.releaseVersionExists()) {
osh.oseLoginDev(constantsutil.FLBLUE_OSE4X_APPS)
appReleaseTag = osh.buildAppImage(appName, appReleaseTag)
osh.oseLogout()
} else {
appReleaseTag = env.RELEASE_VERSION
}
log.info "Displaying artifacts ..."
sh "ls -lt ${deployments_dir}"
}
}
}//Close stage 'Build Image'
stage('Deploy Unit') {
steps {
script {
if(params.UNIT_DEPLOY == true) {
envName="unit"
osh.oseLoginDev(constantsutil.FLBLUE_OSE4X_APPS)
osh.deploy(projectName+"-"+envName, appName, envName, appReleaseTag)
osh.oseLogout()
} else {
log.info "Unit deploy not checked. Not deploying to Unit."
}
}
}
}//Close stage 'Deploy Unit'
stage('Deploy Test') {
steps {
script {
if(params.TEST_DEPLOY == true) {
envName="test"
osh.oseLoginDev(constantsutil.FLBLUE_OSE4X_APPS)
osh.deploy(projectName+"-"+envName, appName, envName, appReleaseTag)
osh.oseLogout()
} else {
log.info "Test deploy not checked. Not deploying to Test."
}
}
}
}//Close stage 'Deploy Test'
stage('Deploy Stage') {
steps {
script {
if(params.STAGE_DEPLOY == true) {
envName="stage"
osh.oseLoginDev(constantsutil.FLBLUE_OSE4X_APPS)
osh.deploy(projectName+"-"+envName, appName, envName, appReleaseTag)
osh.oseLogout()
} else {
log.info "Stage deploy not checked. Not deploying to Stage."
}
}
}
}//Close stage 'Deploy Stage'
stage('Approval: Prod') {
agent none
steps {
echo "Approval for Prod..."
checkRemedyStatus prod: "${params.PROD}", notification: "${params.NOTIFICATION}", ticket: "${params.TICKET}"
}
}
stage('Deploy Prod') {
steps {
script {
if(params.PROD == true) {
envName="prod"
osh.oseLoginProd(constantsutil.FLBLUE_OSE4X_APPS)
osh.promoteAppImage(appName, appReleaseTag,
constantsutil.FLBLUE_OSE4X_APPS.dockerDevhost, "etd-image",
constantsutil.FLBLUE_OSE4X_APPS.dockerProdhost, "etd-image")
osh.deploy(projectName+"-"+envName, appName, envName, appReleaseTag)
osh.oseLogout()
} else {
log.info "Prod deploy not checked. Not deploying to Prod."
}
}
}
}//Close stage 'Deploy Prod'
stage('Baseline code for Prod') {
steps {
script {
if(params.PROD == true) {
wspace.tagAppCodeAndConfigRepo(appReleaseTag)
} else {
log.info "Baselining not done. Not deploying to Prod."
}
}
}
}//Close stage 'Baseline code for Prod'
}
}