-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
94 lines (89 loc) · 2.73 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
// This file is part of the research.fi service
//
// Copyright 2019 Ministry of Education and Culture, Finland
//
// :author: CSC - IT Center for Science Ltd., Espoo Finland [email protected]
// :license: MIT
pipeline {
agent {
node {
label 'nodejs'
}
}
environment {
// Get short version of Git commit hash.
GIT_COMMIT_SHORT = sh(
script: "printf \$(git rev-parse --short ${GIT_COMMIT})",
returnStdout: true
)
}
stages {
/*
Build image using build config "researchfi-frontend-build".
After build is complete, OpenShift's image change trigger automatically updates devel deployment.
Wait until devel pod is ready.
*/
stage('Build image') {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
// Get build config
def buildConfig = openshift.selector("bc", "researchfi-frontend-build")
// Start build and display logs
buildConfig.startBuild().logs("-f")
// New image gets automatically tagged "latest", it is defined in the OpenShift build config.
// Tag image also using short Git commit hash.
// openshift.tag("researchfi-frontend-devel:latest", "researchfi-frontend-devel:${GIT_COMMIT_SHORT}")
}
}
}
}
}
/*
Wait until devel deployment is ready.
At this point the devel environment should be deploying, triggered by a new image from previous step.
*/
/*
stage('Wait devel deployment') {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
sleep 30
timeout(5) {
openshift.selector("dc", "researchfi-frontend-devel-deployment").related('pods').untilEach(1) {
return (it.object().status.phase == "Running")
}
}
}
}
}
}
}
*/
/*
Deploy to production.
Confirm deployment by prompting user.
Production deployment is triggered by tagging the devel "latest" as production "latest".
Also tag the production "latest" with Git commit hash.
*/
/*
stage('Deploy to production') {
steps {
timeout(time: 12, unit: 'HOURS') {
input message: "Deploy to production?", ok: "Deploy"
}
script {
openshift.withCluster() {
openshift.withProject() {
openshift.tag("researchfi-frontend-devel:latest", "researchfi-frontend-production:latest")
// openshift.tag("researchfi-frontend-production:latest", "researchfi-frontend-production:${GIT_COMMIT_SHORT}")
}
}
}
}
}
*/
}
}