Bitbucket is getting a new navigation

We’re rolling out these changes, so the documentation may not match your experience in the Bitbucket Cloud app. Read about the new Bitbucket navigation

Deploy to Google Cloud

Before you begin:

Steps

  1. Clone the Google App Engine example repository.

  2. Create a Google service account key. For more guidance see Google's guide to creating service keys.

  3. Once you have your key file, open up a terminal and browse to the location of your key file.

  4. Encode your file in base64 format and copy the output of the command. Note: For some versions of MacOS the -w 0 is not necessary.

    base64 -w 0 <your-key-file>
  5. In your repo go to Repository settings, under Pipelines, select Repository variables and create a new variable named KEY_FILE and paste the encoded service account credentials.

  6. Configure the pipe and add the variables: PROJECT and KEY_FILE

Variables list

PROJECT (*): The project that owns the app to deploy. 

KEY_FILE (*): base64 encoded Key file for a Google service account.

DEPLOYABLES: List of white space separated yaml files to be passed to gcloud. Default "". If left empty, the app.yaml from the current directory will be used.

VERSION: The version of the app to be created/replaced.

BUCKET: A google cloud storage bucket to store the files associated with the deployment.

IMAGE: Deploy with a specific GCR docker image.

PROMOTE: If true the deployed version receives all traffic, false to not receive traffic.

STOP_PREVIOUS_VERSION: If true the previous version receiving traffic is stopped, false to not stop the previous version.

EXTRA_ARGS: Extra arguments to be passed to the CLI (see Google app deploy docs for more details).

DEBUG: Turn on extra debug information. Default false.

(*) = required variable.

End to end example

Example

image: node:10.15.1 pipelines: default: - step: name: Build and Test script: - npm install - npm test - step: name: Deploy script: - pipe: atlassian/google-app-engine-deploy:1.7.0 variables: KEY_FILE: $KEY_FILE PROJECT: 'my-project'

Advanced examples

Deploy multiple deployables

Example

script: - pipe: atlassian/google-app-engine-deploy:1.7.0 variables: KEY_FILE: $KEY_FILE PROJECT: 'my-project' DEPLOYABLES: 'app-1.yaml app-2.yaml' VERSION: 'alpha' BUCKET: 'gs://my-bucket' IMAGE: 'gcr.io/my/image' PROMOTE: 'true' STOP_PREVIOUS_VERSION: 'true' EXTRA_ARGS: '--verbosity=debug'

Deploy a Python app to gcloud

Example

script: - pipe: atlassian/google-app-engine-deploy:1.7.0 variables: KEY_FILE: $KEY_FILE_PYTHON_APP PROJECT: 'pipes-example-python3-app' DEPLOYABLES: 'hello_world/app.yaml' VERSION: '${BITBUCKET_BUILD_NUMBER}' PROMOTE: 'true' STOP_PREVIOUS_VERSION: 'true' EXTRA_ARGS: '--verbosity=debug --quiet'

Deploy a Spring Boot based Java app build with Maven app.yaml to gcloud

Example

script: - pipe: atlassian/google-app-engine-deploy:1.7.0 variables: KEY_FILE: $KEY_FILE PROJECT: 'pipes-java-maven-spring-boot' DEPLOYABLES: 'target/appengine-staging/app.yaml' VERSION: '${BITBUCKET_BUILD_NUMBER}' EXTRA_ARGS: '--verbosity=debug'

Deploy a Spring Boot based Java app build with Gradle app.yaml to gcloud

Example

script: - pipe: atlassian/google-app-engine-deploy:1.7.0 variables: KEY_FILE: $KEY_FILE PROJECT: 'pipes-java-gradle-spring-boot' DEPLOYABLES: 'build/staged-app/app.yaml' # DEPLOYABLES: 'src/main/WEB-INF/appengine-web.xml' # or you can provide web.xml VERSION: '${BITBUCKET_BUILD_NUMBER}' EXTRA_ARGS: '--verbosity=debug'

Deploy a Spring Boot based Java app build with Gradle WEB-INF/appengine-web.xml to gcloud

Example

script: - pipe: atlassian/google-app-engine-deploy:1.7.0 variables: KEY_FILE: $KEY_FILE PROJECT: 'pipes-java-gradle-spring-boot' DEPLOYABLES: 'src/main/WEB-INF/appengine-web.xml' VERSION: '${BITBUCKET_BUILD_NUMBER}' EXTRA_ARGS: '--verbosity=debug'

Deploy a standard Java app build with Maven app.yaml to gcloud

Example

script: - pipe: atlassian/google-app-engine-deploy:1.7.0 variables: KEY_FILE: $KEY_FILE PROJECT: 'pipes-example-java-app-maven' DEPLOYABLES: 'target/appengine-staging/app.yaml' VERSION: '${BITBUCKET_BUILD_NUMBER}' PROMOTE: 'true' STOP_PREVIOUS_VERSION: 'true' EXTRA_ARGS: '--verbosity=debug'

Deploy a standard Java app build with Maven WEB-INF/appengine-web.xml to gcloud

Example

script: - pipe: atlassian/google-app-engine-deploy:1.7.0 variables: KEY_FILE: $KEY_FILE PROJECT: 'pipes-example-java-app-maven' DEPLOYABLES: 'target/appengine-staging/WEB-INF/appengine-web.xml' VERSION: '${BITBUCKET_BUILD_NUMBER}' PROMOTE: 'true' STOP_PREVIOUS_VERSION: 'true' EXTRA_ARGS: '--verbosity=debug'

Deploy a standard Java app build with Gradle WEB-INF/appengine-web.xml to gcloud

Example

script: - pipe: atlassian/google-app-engine-deploy:1.7.0 variables: KEY_FILE: $KEY_FILE PROJECT: 'pipes-example-java-app-gradle' DEPLOYABLES: 'build/exploded-helloworld/WEB-INF/appengine-web.xml' VERSION: '${BITBUCKET_BUILD_NUMBER}' PROMOTE: 'true' STOP_PREVIOUS_VERSION: 'true' EXTRA_ARGS: '--verbosity=debug'

Deploy a standard Java app build with Gradle app.yaml to gcloud

Example

script: - pipe: atlassian/google-app-engine-deploy:1.7.0 variables: KEY_FILE: $KEY_FILE PROJECT: 'pipes-example-java-app-gradle' DEPLOYABLES: 'build/staged-app/app.yaml' VERSION: '${BITBUCKET_BUILD_NUMBER}' PROMOTE: 'true' STOP_PREVIOUS_VERSION: 'true' EXTRA_ARGS: '--verbosity=debug'

 

Still need help?

The Atlassian Community is here for you.