forked from fabric8-analytics/f8a-server-backbone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
74 lines (62 loc) · 2.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
#!/usr/bin/env groovy
@Library('github.com/msrb/cicd-pipeline-helpers')
def commitId
node('docker') {
def image = docker.image('fabric8-analytics/f8a-server-backbone')
stage('Checkout') {
checkout scm
commitId = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
dir('openshift') {
stash name: 'template', includes: 'template.yaml'
}
}
stage('Unit Tests') {
dockerCleanup()
timeout(30) {
sh './runtests.sh'
}
}
stage('Build') {
dockerCleanup()
docker.build(image.id, '--pull --no-cache .')
}
if (env.BRANCH_NAME == 'master') {
stage('Push Images') {
docker.withRegistry('https://push.registry.devshift.net/', 'devshift-registry') {
image.push('latest')
image.push(commitId)
}
}
}
}
if (env.BRANCH_NAME == 'master') {
node('oc') {
def dc = 'f8a-server-backbone'
lock('f8a_staging') {
stage('Deploy - Stage') {
unstash 'template'
sh "oc --context=rh-idev process -v IMAGE_TAG=${commitId} -f template.yaml | oc --context=rh-idev apply -f -"
}
stage('End-to-End Tests') {
def result
try {
timeout(10) {
sleep 5
sh "oc logs -f dc/${dc}"
def e2e = build job: 'fabric8-analytics-common-master', wait: true, propagate: false, parameters: [booleanParam(name: 'runOnOpenShift', value: true)]
result = e2e.result
}
} catch (err) {
error "Error: ${err}"
} finally {
if (!result?.equals('SUCCESS')) {
sh "oc rollback ${dc}"
error 'End-to-End tests failed.'
} else {
echo 'End-to-End tests passed.'
}
}
}
}
}
}