-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
56 lines (53 loc) · 2.13 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
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
disableConcurrentBuilds()
timestamps()
}
agent { label 'gradle' }
parameters {
string(name: 'SERVICE_NAME', defaultValue: 'nexus3-custom', description: 'Nexus 3 openshift service name')
string(name: 'VOLUME_CAPACITY', defaultValue: '10Gi', description: 'Volume capacity of the PVC for Nexus 3 storage')
}
stages {
stage('Process resources') {
steps {
checkout scm
container('gradle') {
sh "gradle -Pci=true clean transformScriptToJson"
}
}
}
stage('Build') {
steps {
container('gradle') {
script {
openshift.withCluster() {
openshift.withProject('cicd') {
sh "gradle transformScriptToJson"
// create BuildConfig resources
sh "helm template --name ${params.SERVICE_NAME} --set nameOverride=${params.SERVICE_NAME} charts/openshift-build | oc apply -n cicd -f -"
//start build
def buildSelector = openshift.selector('bc', "${params.SERVICE_NAME}").startBuild('--from-dir=.')
buildSelector.logs('-f')
timeout(5) {
buildSelector.untilEach(1) {
return it.object().status.phase == "Complete"
}
}
}
}
}
}
}
}
stage('Deploy') {
steps {
container('gradle') {
//TODO: ensure unique version with commit id or so
sh "helm template --name ${params.SERVICE_NAME} -f charts/openshift-build/values.yaml charts/nexus3 | oc apply -n cicd -f -"
}
}
}
}
}