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 uploaded when you deploy updates to your application.

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.

App Engine

Standard environment

Java

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.

Python

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.

Go

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

Flexible environment

Java

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.

Python

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

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

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.

Compute Engine

Java

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.

Python

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

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

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.

Container Engine

Java

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 Container Engine cluster, including the source-context.json file.

Python

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 Container Engine cluster.

Node.js

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 Container Engine cluster, including the source-context.json file.

Go

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 Container Engine cluster, including the source-context.json file.

Send feedback about...

Stackdriver Debugger Documentation