-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.pipeline.yml
91 lines (89 loc) · 2.46 KB
/
ui.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
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
---
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}
- name: CATALOG_APP_NAME
value: ${CATALOG_APP_NAME}
- name: ORDERS_APP_NAME
value: ${ORDERS_APP_NAME}
- name: CONVERSATION_WORKSPACE
value: NOT_SET
- name: REGION_ID
value: ${REGION_ID}
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 conversation standard insurance-bot-conversation
cf create-service cloudantNoSQLDB Lite ${PREFIX}insurance-bot-db
# Set app's env vars
domain=".mybluemix.net"
case "${REGION_ID}" in
ibm:yp:eu-gb)
domain=".eu-gb.mybluemix.net"
;;
ibm:yp:au-syd)
domain=".au-syd.mybluemix.net"
;;
esac
if ! cf app $CF_APP; then
cf push $CF_APP -n $CF_APP -f $MANIFEST --no-start
cf set-env $CF_APP CATALOG_URL https://$CATALOG_APP_NAME$domain
cf set-env $CF_APP ORDERS_URL https://$ORDERS_APP_NAME$domain
cf set-env $CF_APP CONVERSATION_WORKSPACE $CONVERSATION_WORKSPACE
cf start $CF_APP
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 --no-start
cf set-env $CF_APP CATALOG_URL https://$CATALOG_APP_NAME$domain
cf set-env $CF_APP ORDERS_URL https://$ORDERS_APP_NAME$domain
cf set-env $CF_APP CONVERSATION_WORKSPACE $CONVERSATION_WORKSPACE
cf start $CF_APP
cf delete $OLD_CF_APP -f
fi