Created
May 17, 2018 20:11
-
-
Save RodrigoPinho/69eed60147b3fbe1b44ebe6096da51e3 to your computer and use it in GitHub Desktop.
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
# This is build configuration for Java and Docker. | |
image: maven:3.3.9 | |
options: | |
docker: true | |
pipelines: | |
custom: | |
schedule-ci: #Continuous Integration | |
- step: | |
caches: | |
- maven | |
script: | |
- mvn clean package | |
deployment-to-prod: #Deployment to Production | |
- step: | |
caches: | |
- maven | |
script: | |
- mvn clean package | |
# Downloading and installing gcloud | |
- curl -o /tmp/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-161.0.0-linux-x86_64.tar.gz | |
- tar -xvf /tmp/google-cloud-sdk.tar.gz -C /tmp/ | |
- /tmp/google-cloud-sdk/install.sh -q | |
- source /tmp/google-cloud-sdk/path.bash.inc | |
# Installing kubectl | |
- gcloud components install kubectl -q | |
# Authentication | |
- echo $GCLOUD_API_KEYFILE | base64 --decode --ignore-garbage > ./gcloud-api-key.json | |
- gcloud auth activate-service-account --key-file gcloud-api-key.json | |
- gcloud config set project $GCLOUD_PROJECT | |
- gcloud container clusters get-credentials $GCLOUD_CLUSTER --zone=$GCLOUD_ZONE | |
# Building images | |
- docker build . -t gcr.io/$GCLOUD_PROJECT/$APP_NAME:$BITBUCKET_COMMIT | |
# Pushing SHA1 image | |
- gcloud docker -- push gcr.io/$GCLOUD_PROJECT/$APP_NAME:$BITBUCKET_COMMIT | |
# Pushing latest image | |
- docker tag gcr.io/$GCLOUD_PROJECT/$APP_NAME:$BITBUCKET_COMMIT gcr.io/$GCLOUD_PROJECT/$APP_NAME:latest | |
- gcloud docker -- push gcr.io/$GCLOUD_PROJECT/$APP_NAME:latest | |
# Deploy the image | |
- kubectl set image deployment/app-jee app-jee=gcr.io/$GCLOUD_PROJECT/$APP_NAME:$BITBUCKET_COMMIT | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment