-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Frederic Lavigne
committed
Jan 2, 2017
1 parent
2f5b2fb
commit 426bb56
Showing
3 changed files
with
302 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,72 @@ | ||
--- | ||
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 | ||
if [ -f ${REPO_BRANCH}-manifest.yml ]; then | ||
MANIFEST=${REPO_BRANCH}-manifest.yml | ||
fi | ||
echo "Using manifest file: $MANIFEST" | ||
# and a prefix for services if not building the master branch | ||
if [ "$REPO_BRANCH" == "master" ]; then | ||
echo "No prefix for master branch" | ||
PREFIX="" | ||
else | ||
PREFIX=$REPO_BRANCH"-" | ||
echo "Using prefix: $PREFIX" | ||
fi | ||
# 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 | ||
--- | ||
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 | ||
if [ -f ${REPO_BRANCH}-manifest.yml ]; then | ||
MANIFEST=${REPO_BRANCH}-manifest.yml | ||
fi | ||
echo "Using manifest file: $MANIFEST" | ||
# and a prefix for services if not building the master branch | ||
if [ "$REPO_BRANCH" == "master" ]; then | ||
echo "No prefix for master branch" | ||
PREFIX="" | ||
else | ||
PREFIX=$REPO_BRANCH"-" | ||
echo "Using prefix: $PREFIX" | ||
fi | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,88 @@ | ||
--- | ||
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: 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 | ||
if [ -f ${REPO_BRANCH}-manifest.yml ]; then | ||
MANIFEST=${REPO_BRANCH}-manifest.yml | ||
fi | ||
echo "Using manifest file: $MANIFEST" | ||
# and a prefix for services if not building the master branch | ||
if [ "$REPO_BRANCH" == "master" ]; then | ||
echo "No prefix for master branch" | ||
PREFIX="" | ||
else | ||
PREFIX=$REPO_BRANCH"-" | ||
echo "Using prefix: $PREFIX" | ||
fi | ||
# Create CF services | ||
cf create-service cloudantNoSQLDB Lite ${PREFIX}insurance-policy-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 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 start $CF_APP | ||
cf delete $OLD_CF_APP -f | ||
fi | ||
--- | ||
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: 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 | ||
if [ -f ${REPO_BRANCH}-manifest.yml ]; then | ||
MANIFEST=${REPO_BRANCH}-manifest.yml | ||
fi | ||
echo "Using manifest file: $MANIFEST" | ||
# and a prefix for services if not building the master branch | ||
if [ "$REPO_BRANCH" == "master" ]; then | ||
echo "No prefix for master branch" | ||
PREFIX="" | ||
else | ||
PREFIX=$REPO_BRANCH"-" | ||
echo "Using prefix: $PREFIX" | ||
fi | ||
# Create CF services | ||
cf create-service cloudantNoSQLDB Lite ${PREFIX}insurance-policy-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 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 start $CF_APP | ||
cf delete $OLD_CF_APP -f | ||
fi |
Oops, something went wrong.