forked from robipozzi/windfire-restaurants-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
56 lines (53 loc) · 2.47 KB
/
Jenkinsfile
File metadata and controls
56 lines (53 loc) · 2.47 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
pipeline {
options {
// set a timeout of 60 minutes for this pipeline
timeout(time: 60, unit: 'MINUTES')
}
environment {
APP_NAME = "windfire-restaurants-backend"
DEV_PROJECT = "windfire"
STAGE_PROJECT = "windfire-stage"
PROD_PROJECT = "windfire-prod"
APP_GIT_URL = "https://github.com/robipozzi/windfire-restaurants-node"
}
agent {
node {
label 'nodejs'
}
}
stages {
stage('Deploy to DEV environment') {
steps {
echo '###### Deploy to DEV environment ######'
script {
openshift.withCluster() {
openshift.withProject("$DEV_PROJECT") {
echo "Using project: ${openshift.project()}"
// If BuildConfig already exists, start a new build to update the application
if (openshift.selector("bc", APP_NAME).exists()) {
echo "BuildConfig " + APP_NAME + " exists, start new build to update app ..."
// Start new build (it corresponds to oc start-build <buildconfig>)
def bc = openshift.selector("bc", "${APP_NAME}")
bc.startBuild()
// If a Route does not exist, expose the Service and create the Route
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()
}
}
// If BuildConfig does not exist, deploy a new application using an OpenShift Template
else{
echo "BuildConfig " + APP_NAME + " does not exist, creating app ..."
openshift.newApp('deployment/openshift/windfire-restaurants-backend-template.yaml')
}
def route = openshift.selector("route", APP_NAME)
echo "Test application with "
def result = route.describe()
}
}
}
}
}
}
}