forked from fabric8-analytics/fabric8-analytics-pgbouncer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
74 lines (63 loc) · 2.07 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
#!/usr/bin/env groovy
@Library('github.com/msrb/cicd-pipeline-helpers')
def commitId
node('docker') {
def image = docker.image('bayesian/coreapi-pgbouncer')
stage('Checkout') {
checkout scm
commitId = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
dir('openshift') {
stash name: 'template', includes: 'template.yaml'
}
}
stage('Build') {
docker.build(image.id, '--pull --no-cache .')
}
stage('Test') {
dockerCleanup()
dir('tests') {
timeout(5) {
sh './run_integration_tests.sh'
}
}
}
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 = 'bayesian-pgbouncer'
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.'
}
}
}
}
}
}