This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
forked from tobru/nextcloud-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
99 lines (95 loc) · 4.58 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
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 fixed nextcloud image') {
steps {
script {
if (env.BUILD_FIXED_IMAGE.toBoolean()) {
// consider changes in nc_image_fix/Dockerfile
openshift.withCluster() {
openshift.withProject(/*"${env.PROJECT_NAME}"*/) {
def buildSelector = openshift.selector("bc", 'nextcloud-image')
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('Rebuild nginx image') {
steps {
script {
// consider changes in Dockerfile and nginx.conf
openshift.withCluster() {
openshift.withProject(/*"${env.PROJECT_NAME}"*/) {
def buildSelector = openshift.selector("bc", 'nginx')
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 nextcloud.yaml and nextcloud-cron.yaml
openshift.withCluster() {
openshift.withProject(/*"${env.PROJECT_NAME}"*/) {
def template = readFile 'nextcloud.yaml'
def args = ['-p', "PVC_SIZE=${env.PVC_SIZE}",
'-p', "REPLICAS=${env.REPLICAS}",
'-p', "NEXTCLOUD_HOST=${env.NEXTCLOUD_HOST}"]
def existing_fpm_cm = openshift.selector("cm", "fpm-confd").object()
if (existing_fpm_cm.data["www.overloaded.conf"]) {
args += ['-p', "FPM_PARAMETERS=" + existing_fpm_cm.data["www.overloaded.conf"]]
}
if (env.BUILD_FIXED_IMAGE.toBoolean()) {
args += ['-p', "NEXTCLOUD_IMAGESTREAM_NAME=nextcloud-fixed",
'-p', "NEXTCLOUD_IMAGE_TAG=latest"]
} else {
args += ['-p', "NEXTCLOUD_IMAGE_TAG=${env.NEXTCLOUD_IMAGE_TAG}"]
}
def config = openshift.process(template, args)
openshift.apply(config)
def cronTemplate = readFile 'nextcloud-cron.yaml'
// The cron job will always be done with the unfixed image
def cronConfig = openshift.process(cronTemplate,
'-p', "NEXTCLOUD_IMAGE_TAG=${env.NEXTCLOUD_IMAGE_TAG}")
openshift.apply(cronConfig)
def templateName = 'nextcloud'
/*def rm = openshift.selector("dc", templateName)
.rollout().latest()*/
timeout(10) {
openshift.selector("dc", templateName)
.related('pods').untilEach(1) {
return (it.object().status.phase == "Running")
}
}
}
}
}
}
}
}
}