This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
114 lines (109 loc) · 5.06 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
pipeline {
agent any
stages {
stage('Build info') {
steps {
sh 'env'
}
}
stage('Checkout sources') {
steps {
checkout changelog: false, poll: false,
scm: [$class: 'GitSCM', branches: [[name: "${env.GIT_BRANCH}"]],
doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [],
userRemoteConfigs: [[url: "${env.GIT_URL}"]]]
}
}
stage('Rebuild forked openproject image') {
steps {
script {
if (env.BUILD_FORK_IMAGE.toBoolean()) {
// increase timeout
timeout(time: 60, unit: 'MINUTES') {
// consider changes in nc_image_fix/Dockerfile
openshift.withCluster() {
openshift.withProject(/*"${env.PROJECT_NAME}"*/) {
def buildSelector = openshift.selector("bc", 'community-fork')
buildSelector.startBuild("--follow=true")
/* Alternatively to "--follow=true":
* Do some parallel tasks while building.
* When needed to wait for the build again and show logs, do:
* build.logs('-f') */
}
}
}
}
}
}
}
stage('Apply configuration update') {
steps {
script {
// consider changes in openproject.yaml
openshift.withCluster() {
openshift.withProject(/*"${env.PROJECT_NAME}"*/) {
def template = readFile 'openproject.yaml'
def config = null
if (env.BUILD_FORK_IMAGE.toBoolean()) {
config = openshift.process(template,
'-p', "PVC_SIZE=${env.PVC_SIZE}",
'-p', "OPENPROJECT_HOST=${env.OPENPROJECT_HOST}",
'-p', "DATABASE_SECRET=${env.DATABASE_SECRET}",
'-p', "COMMUNITY_IMAGE_KIND=ImageStreamTag",
'-p', "COMMUNITY_IMAGE_NAME=community-fork",
'-p', "COMMUNITY_IMAGE_TAG=${env.COMMUNITY_IMAGE_TAG}")
} else {
config = openshift.process(template,
'-p', "PVC_SIZE=${env.PVC_SIZE}",
'-p', "OPENPROJECT_HOST=${env.OPENPROJECT_HOST}",
'-p', "DATABASE_SECRET=${env.DATABASE_SECRET}",
'-p', "COMMUNITY_IMAGE_NAME=${env.COMMUNITY_IMAGE_NAME}",
'-p', "COMMUNITY_IMAGE_TAG=${env.COMMUNITY_IMAGE_TAG}")
}
openshift.apply(config)
}
}
}
}
}
stage('Rebuild openproject-for-openshift image') {
steps {
script {
// consider changes in Dockerfile and nginx.conf
openshift.withCluster() {
openshift.withProject(/*"${env.PROJECT_NAME}"*/) {
// set timeout to 10 minutes
timeout(time: 10, unit: 'MINUTES') {
def buildSelector = openshift.selector("bc", 'community-app')
buildSelector.startBuild("--follow=true")
/* Alternatively to "--follow=true":
* Do some parallel tasks while building.
* When needed to wait for the build again and show logs, do:
* build.logs('-f') */
}
}
}
}
}
}
stage('Wait for rollout to complete') {
steps {
script {
openshift.withCluster() {
openshift.withProject(/*"${env.PROJECT_NAME}"*/) {
def templateName = 'community'
/*def rm = openshift.selector("dc", templateName)
.rollout().latest()*/
timeout(10) {
openshift.selector("dc", templateName)
.related('pods').untilEach(1) {
return (it.object().status.phase == "Running")
}
}
}
}
}
}
}
}
}