source-context.json
file, which is generated from a Git repository
and deployed with your application.
Before you begin
Make sure your source code is in a Git repository.
Make sure the Debugger API is enabled and your environment is configured.
Setup on Google Cloud
Follow the steps below to select your source code automatically:
Java
App Engine standard environment
No additional setup. When you deploy your app, a WEB-INF/classes/source-context.json
file is automatically generated and uploaded with your application.
App Engine flexible environment, Compute Engine, GKE, and Cloud Run
- Commit your latest changes.
- Run the following in the root directory of your local Git repository:
-
Deploy (or redeploy) your app from the Git repository, including the
source-context.json
file.
gcloud debug source gen-repo-info-file --output-directory="WEB-INF/classes/"
The correct version of your source code now appears automatically on the Debugger page.
Python
App Engine standard environment
No additional setup. Verify that Deployed files is selected in the Debugger panel.
App Engine flexible environment, Compute Engine, GKE, and Cloud Run
- Commit your latest changes.
- Run the following in the root directory of your local Git repository:
-
Deploy (or redeploy) your app from the Git repository, including the
source-context.json
file.
gcloud debug source gen-repo-info-file --output-directory=[MODULE_PACKAGE_DIR]
[MODULE_PACKAGE_DIR]
is the top level of your app directory.
The correct version of your source code now appears automatically on the Debugger page.
Node.js
App Engine standard environment
No additional setup. Verify that Deployed files is selected in the Debugger panel.
App Engine flexible environment, Compute Engine, GKE, and Cloud Run
- Commit your latest changes.
- Run the following in the root directory of your local Git repository:
-
Deploy (or redeploy) your app from the Git repository, including the
source-context.json
file.
gcloud debug source gen-repo-info-file --output-directory=[MODULE_PACKAGE_DIR]
[MODULE_PACKAGE_DIR]
is the top level of your app directory.
The correct version of your source code now appears automatically on the Debugger page.
.Net Core
- Commit your latest changes.
- Run the following in the root directory of your local Git repository:
-
Deploy (or redeploy) your app from the Git repository, including the
source-context.json
file.
gcloud debug source gen-repo-info-file --output-directory=[MODULE_PACKAGE_DIR]
[MODULE_PACKAGE_DIR]
is the top level of your app directory.
The correct version of your source code now appears automatically on the Debugger page.
Example workflow and folder structure
To generate the source-context.json
file, perform the following steps:
Commit your latest changes:
git commit -m "Commit message"
Generate the
source-context.json
file by running the following command from the app's root directory:gcloud debug source gen-repo-info-file
For more information on the
gcloud debug source gen-repo-info-file
, run the following command:gcloud debug source gen-repo-info-file --help
Verify that the
source-context.json
file is colocated with the app's source code. Your folder structure should be similar to the following:App-directory/ main.py app.yaml source-context.json
Redeploy your application.