forked from monodot/hello-java-spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
69 lines (58 loc) · 2.49 KB
/
Jenkinsfile
File metadata and controls
69 lines (58 loc) · 2.49 KB
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
// Based on:
// https://raw.githubusercontent.com/redhat-cop/container-pipelines/master/basic-spring-boot/Jenkinsfile
pipeline {
options {
// set a timeout of 60 minutes for this pipeline
timeout(time: 5, unit: 'MINUTES')
}
environment {
DEV_PROJECT = "mavc23-dev"
APP_NAME = "hello-java-spring-boot"
APP_GIT_URL = "https://github.com/m1k3dcdc/hello-java-spring-boot.git"
}
agent any
stages {
stage('Create Container Image') {
steps {
echo '### Create Container Image... ###'
script {
openshift.withCluster() {
openshift.withProject("$DEV_PROJECT") {
echo "### Using project: ${openshift.project()}"
def buildConfigExists = openshift.selector("bc", "hello-java-spring-boot-bc").exists()
echo "### BuildConfig: " + APP_NAME + " exists, start new build to update app ..."
if (!buildConfigExists) {
echo "### newBuild " + APP_NAME + " does not exist"
openshift.newBuild("--name=hello-java-spring-boot-bc", "--image=docker.io/m1k3pjem/hello-java-spring-boot", "--binary")
if (!openshift.selector("route", APP_NAME).exists()) {
echo "### Route " + APP_NAME + " does not exist, exposing service ..."
//def service = openshift.selector("service", APP_NAME)
//service.expose()
} else {
echo "### Route " + APP_NAME + " exist"
}
}
openshift.selector("bc", "hello-java-spring-boot-bc").startBuild("--from-dir=.", "--follow")
}
}
}
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
script {
openshift.withCluster() {
openshift.withProject("mavc23-dev") {
def deployment = openshift.selector("dc", "hello-java-spring-boot")
if(!deployment.exists()){
//openshift.newApp('hello-java-spring-boot', "--as-deployment-config").narrow('svc').expose()
sh "oc apply -f . -n mavc23-dev"
}
}
}
}
}
}
}
}