Skip to content
Snippets Groups Projects
Commit 9f900355 authored by Jagan Gottimukkula's avatar Jagan Gottimukkula
Browse files

added gcp deployment scripts

parent 40398c2d
Branches
Tags
1 merge request!6Trusted ibm
......@@ -33,4 +33,4 @@ handlers:
script: this field is required, but ignored
env_variables:
GOOGLE_CLOUD_PROJECT: "opendes"
GOOGLE_CLOUD_PROJECT: "GOOGLE_CLOUD_PROJECT_PLACE_HOLDER"
#!/bin/bash
# Exit as soon as a command fails
set -e
echo " Project = $GCLOUD_PROJECT"
echo " Source branch = $BUILD_SOURCEBRANCHNAME"
echo " Build definition = $BUILD_DEFINITIONNAME"
echo " Build number = $BUILD_BUILDNUMBER"
echo "current working directory"
pwd
echo "working directory contents"
ls
DEPLOY_DIR="deploy_dir"
mkdir -p $DEPLOY_DIR
cp app.yaml $DEPLOY_DIR
cp indexer-service-gcp-*.jar $DEPLOY_DIR
# Go to deploy directory
cd $DEPLOY_DIR
# apply sed to set PROJECT_ID with its value in app.yaml
echo "Replacing GOOGLE_CLOUD_PROJECT_PLACE_HOLDER with GCLOUD_PROJECT"
sed -i "s|GOOGLE_CLOUD_PROJECT_PLACE_HOLDER|$GCLOUD_PROJECT|g" app.yaml
cat app.yaml
# check the current deployed version of the same service
SERVICE_NAME="os-indexer"
count=$(gcloud app services list --project $GCLOUD_PROJECT | grep $SERVICE_NAME | wc -l)
if [ $count -gt 0 ]; then
CURRENT_VERSION=$(gcloud app services describe $SERVICE_NAME --project $GCLOUD_PROJECT --format=json | jq --raw-output '.split.allocations | keys[0]')
else
CURRENT_VERSION=""
fi
NEW_VERSION=$BUILD_BUILDNUMBER #to keep it unique
NEW_VERSION=$(echo "$NEW_VERSION" | tr _ - | tr . - | tr '[:upper:]' '[:lower:]')
echo "Current version = $CURRENT_VERSION"
echo "Version to be deployed = $NEW_VERSION"
if [ "$NEW_VERSION" != "$CURRENT_VERSION" -o "$BUILD_FORCE_DEPLOY" = "true" ]
then
gcloud app deploy --quiet --version=$NEW_VERSION --project=$GCLOUD_PROJECT app.yaml
else
echo "Not deploying the application because $NEW_VERSION is already deployed and force deploy flag is not set to true"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment