Selecting Source Code Automatically

Stackdriver Debugger uses source context information to display the correct version of your source code on the Debug page. The source context information is captured in a source-context.json file, which must be generated and deployed with your application.

Java

App Engine Standard

When you deploy your app with the appcfg.sh update command, a WEB-INF/classes/source-context.json file is automatically generated and uploaded with your application.

Make sure to run your deployment command from the git directory.

See Java 8 Runtime Environment for more information.

App Engine Flexible

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory="WEB-INF/classes/"

Then, deploy (or redeploy) your application to your App Engine app, including the source-context.json file.

See Google App Engine Java Flexible Environment Documentation for more information.

Google Kubernetes Engine

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory="WEB-INF/classes/"

Then, deploy (or redeploy) your application to your Google Kubernetes Engine cluster, including the source-context.json file.

Compute Engine

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory="WEB-INF/classes/"

Then, deploy (or redeploy) your application to your Compute Engine instance, including the source-context.json file.

If you use the maven-git-commit-id-plugin Maven plugin, this plugin generates a git.properties file that contains source context information. The git.properties file is automatically injected into your application. There is no need to generate the source-context.json file.

Python

App Engine Standard

For Python 2, when you deploy your app with the appcfg.py update command, a WEB-INF/classes/source-context.json file is generated and uploaded with your application.

Make sure to run your deployment command from the git directory.

For Python 3, to generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory=[MODULE_PACKAGE_DIR]

Where [MODULE_PACKAGE_DIR] is the top level of your Python module package. For example:
--output-directory="./my-python-app/"

Then, deploy (or redeploy) your application to your App Engine app.

See Google App Engine Python Standard Environment Documentation for more information.

App Engine Flexible

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory=[MODULE_PACKAGE_DIR]

Where [MODULE_PACKAGE_DIR] is the top level of your Python module package. For example:
--output-directory="./my-python-app/"

Then, deploy (or redeploy) your application to your App Engine app.

See Google App Engine Python Flexible Environment Documentation for more information.

Google Kubernetes Engine

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory=[MODULE_PACKAGE_DIR]

Where [MODULE_PACKAGE_DIR] is the top level of your Python module package. For example:
--output-directory="./my-python-app/"

Then, deploy (or redeploy) your application to your Google Kubernetes Engine cluster.

Compute Engine

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory=[MODULE_PACKAGE_DIR]

Where [MODULE_PACKAGE_DIR] is the top level of your Python module package. For example:
--output-directory="./my-python-app/"

Then, deploy (or redeploy) your application to your Compute Engine instance.

Node.js

App Engine Standard

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory [DIRECTORY]

Where [DIRECTORY] is the top level directory for your application containing your package.json file.

Then, deploy (or redeploy) your application to your Compute Engine instance, including the source-context.json file.

See Node.js Runtime Environment for more information.

App Engine Flexible

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory [DIRECTORY]

Where [DIRECTORY] is the top level directory for your application containing your package.json file.

Then, deploy (or redeploy) your application to your Compute Engine instance, including the source-context.json file.

See Google App Engine Node.js Flexible Environment Documentation for more information.

Google Kubernetes Engine

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file

Then, deploy (or redeploy) your application to your Google Kubernetes Engine cluster, including the source-context.json file.

Compute Engine

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory [DIRECTORY]

Where [DIRECTORY] is the top level directory for your application containing your package.json file.

Then, deploy (or redeploy) your application to your Compute Engine instance, including the source-context.json file.

Go

App Engine Standard

Not available yet.

App Engine Flexible

Not available yet.

Google Kubernetes Engine

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory DIRECTORY

We recommend specifying your application's root directory as the output directory.

Then, deploy (or redeploy) your application to your Google Kubernetes Engine cluster, including the source-context.json file.

Compute Engine

To generate the source context file, commit any outstanding changes and push them to your remote repository, then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory DIRECTORY

We recommend specifying your application's root directory as the output directory.

Then, deploy (or redeploy) your application to your Compute Engine instance, including the source-context.json file.

.NET Core

App Engine Standard

Not available yet.

App Engine Flexible

To generate the source context file, commit any outstanding changes, push them to your remote repository, and then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory DIRECTORY

We recommend specifying your application's root directory as the output directory.

Then, deploy (or redeploy) your application to your Google Kubernetes Engine cluster, including the source-context.json file.

See Google App Engine .Net Environment Documentation for more information.

Google Kubernetes Engine

To generate the source context file, commit any outstanding changes, push them to your remote repository, and then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory DIRECTORY

We recommend specifying your application's root directory as the output directory.

Then, deploy (or redeploy) your application to your Google Kubernetes Engine cluster, including the source-context.json file.

Compute Engine

To generate the source context file, commit any outstanding changes, push them to your remote repository, and then run the following in the root directory of your local Git repository.

gcloud debug source gen-repo-info-file --output-directory DIRECTORY

We recommend specifying your application's root directory as the output directory.

Then, deploy (or redeploy) your application to your Compute Engine instance, including the source-context.json file.

Was this page helpful? Let us know how we did:

Send feedback about...

Stackdriver Debugger Documentation