-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatalog-api.pipeline.yml
66 lines (63 loc) · 1.54 KB
/
catalog-api.pipeline.yml
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
---
stages:
- name: BUILD
inputs:
- type: git
branch: ${REPO_BRANCH}
service: ${REPO}
triggers:
- type: commit
jobs:
- name: Build
type: builder
- name: DEPLOY
inputs:
- type: job
stage: BUILD
job: Build
triggers:
- type: stage
properties:
- name: REPO_BRANCH
value: ${REPO_BRANCH}
jobs:
- name: Blue/Green Deploy
type: deployer
target:
region_id: ${REGION_ID}
organization: ${ORG_NAME}
space: ${SPACE_NAME}
application: ${CF_APP_NAME}
script: |-
#!/bin/bash
# The branch may use a custom manifest
MANIFEST=manifest.yml
PREFIX=""
if [ -f ${REPO_BRANCH}-manifest.yml ]; then
MANIFEST=${REPO_BRANCH}-manifest.yml
PREFIX=$REPO_BRANCH"-"
fi
echo "Using manifest file: $MANIFEST"
echo "Using prefix: $PREFIX"
# Create CF services
cf create-service cloudantNoSQLDB Lite ${PREFIX}insurance-policy-db
cf create-service tradeoff_analytics standard insurance-tradeoff-analytics
if ! cf app $CF_APP; then
cf push $CF_APP -n $CF_APP -f $MANIFEST
else
OLD_CF_APP=${CF_APP}-OLD-$(date +"%s")
rollback() {
set +e
if cf app $OLD_CF_APP; then
cf logs $CF_APP --recent
cf delete $CF_APP -f
cf rename $OLD_CF_APP $CF_APP
fi
exit 1
}
set -e
trap rollback ERR
cf rename $CF_APP $OLD_CF_APP
cf push $CF_APP -n $CF_APP -f $MANIFEST
cf delete $OLD_CF_APP -f
fi