-
Notifications
You must be signed in to change notification settings - Fork 248
/
Jenkinsfile.ocp
59 lines (55 loc) · 1.98 KB
/
Jenkinsfile.ocp
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
// Basic OpenShift Pipeline - Uses an existing BuildConfig and a manually
// triggered DeploymentConfig
pipeline {
/* Which container to bring up for the build. Pick one of the templates configured in Kubernetes plugin. */
tools {
maven 'Apache Maven 3.0.5'
jdk 'Open JDK 8'
oc 'oc'
}
agent any
stages {
stage("Build EAR") {
steps {
checkout scm
sh "mvn clean package"
}
}
stage("Build Image") {
steps {
script {
openshift.withCluster('mycluster') {
openshift.withProject("${env.DEPLOYED_PROJECT}") {
def deployedAppName = "${env.DEPLOYED_APP_NAME}"
echo "Disabling ImageChange trigger on current deployment ..."
def result = openshift.raw("set","triggers", "dc/${env.DEPLOYED_APP_NAME}","--manual")
echo "set triggers return message: ${result.out}"
echo "Starting build using BuildConfig ${deployedAppName} ..."
openshift.selector("bc", deployedAppName).startBuild("--from-dir=.", "--wait")
}
}
}
}
}
stage('Deploy') {
steps {
script {
openshift.withCluster('mycluster') {
openshift.withProject("${env.DEPLOYED_PROJECT}") {
def deployedAppName = "${env.DEPLOYED_APP_NAME}"
echo "Perform a rolling update of newly built image on current deployment ..."
def rm = openshift.selector("dc",deployedAppName).rollout().latest()
echo "Wait for Deployment to start rolling out and then wait for it to complete ..."
sleep 60
timeout(5) {
openshift.selector("dc", deployedAppName).related('pods').untilEach(1) {
return (it.object().status.phase == "Running")
}
}
}
}
}
}
}
}
}