forked from VeerMuchandi/bluegreen
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Jenkinsfile.backup
45 lines (37 loc) · 1.37 KB
/
Jenkinsfile.backup
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
node {
stage 'Build image and deploy in Dev'
echo 'Building docker image and deploying to Dev'
buildApp('app-dev')
stage 'Approve to QA'
input 'Approve to QA?'
stage 'Deploy to QA'
echo 'Deploying to QA'
deployApp('app-dev', 'app-qa')
stage 'run integration testing'
echo 'Running integration tests'
sh 'sleep 30s'
stage 'Approve to Production'
input 'Approve to Production?'
stage 'Deploy to Production'
echo 'Deploying to Production'
deployApp('app-dev', 'app-prod')
}
// Creates a Build and triggers it
def buildApp(String project){
sh "oc login https://10.1.2.2:8443 --insecure-skip-tls-verify -u openshift-dev -p devel"
sh "oc project ${project}"
// sh "oc start-build bluegreen"
openshiftBuild(buildConfig: 'bluegreen', showBuildLogs: 'true')
}
// Tag the ImageStream from an original project to force a deployment
def deployApp(String origProject, String project){
sh "oc project ${project}"
sh "oc policy add-role-to-user system:image-puller system:serviceaccount:${project}:default -n ${origProject}"
sh "oc tag ${origProject}/bluegreen:latest ${project}/bluegreen:latest"
appDeploy()
}
// Deploy the project based on an existing ImageStream
def appDeploy(){
sh "oc new-app bluegreen || echo 'Application already exists'"
sh "oc expose svc bluegreen || echo 'Service already exposed'"
}