Watch modes in Cloud Code for IntelliJ

Cloud Code allows you to quickly apply changes to your application during a development or debug session for a faster feedback loop. This lets you run your Kubernetes and emulated Cloud Run sessions in watch mode.

Settings for Kubernetes and Cloud Run configurations

You can configure watch mode in the Cloud Code Kubernetes and Cloud Run configurations at Run > Edit configurations on the Run tab:

Watch mode Description
On demand
  • The default value for new run configurations.
  • Cloud Code only rebuilds and redeploys your application when triggered. To trigger On-demand mode, click On demand trigger button Trigger Build and Deploy or press Option+Cmd+Comma on Mac OS or Ctrl+Alt+Comma on Windows (the default key bindings).
On file save
  • Rebuilds and redeploys your application after you save any changes.
  • This option is not available in debug mode.
Watch mode options

Customizing the Trigger Build and Deploy keymap

The default key bindings for On demand trigger button Trigger Build and Deploy are:

  • Mac OS: Option+Cmd+Comma
  • Windows: Ctrl+Alt+Comma

To change the default key bindings:

  1. Navigate to Preferences > Keymap.
  2. In the Keymap search bar, enter "trigger build and deploy".
  3. Right-click the Trigger Build and Deploy search result and select Add Keyboard Shortcut.
  4. Enter shortcut combination you prefer (for example, Shift+R) and click OK, then click OK in the Preferences window. This adds your new key binding to the Trigger Build and Deploy function, so that both the default and your new key binding will work.
  5. You can also remove the default key binding by right-clicking the Trigger Build and Deploy search result and selecting the Remove option.

Applying changes while debugging

With Cloud Code, you can debug an application while making changes to, and iterating on, source code. This is available for Kubernetes development and Cloud Run local development.

To apply changes to your code while debugging, perform the following:

  1. Ensure On-demand mode is enabled in Run > Edit Configurations (the default option).
  2. Launch the run configuration in debug mode by clicking Debug icon Debug.

Common use case

This section outlines a common scenario of how you can debug with watch mode enabled in your IDE.

Debugging a Kubernetes application with watch mode enabled

You're a developer building an application that runs on Kubernetes, and use Cloud Code to iterate on your app. You discovered a bug in your code.

  1. You launch the Develop on Kubernetes run configuration, and:
    1. Select On demand to rebuild and redeploy the app.
    2. Launch the run configuration in debug mode by clicking Debug icon Debug.
  2. You set a breakpoint near the expected bug, launch the app, and use the debugger to figure out what the bug is.
  3. You fix the bug while the development session is still running (the debugger is still attached). You now want to confirm that the issue is fixed.
  4. You trigger On-demand mode which tells Cloud Code and Skaffold to rebuild and redeploy the application, by clicking On demand trigger button Trigger Build and Deploy or pressing Option+Cmd+Comma on Mac OS or Ctrl+Alt+Comma on Windows (the default key bindings).
  5. A notification appears and asks you to confirm: "Redeploying your changes will cause the debugger to be stopped and reattached, potentially losing your current debug state". You have the option to either cancel, continue, or to never be notified again.
  6. After clicking continue:
    • The debugger is terminated
    • The application is rebuilt and redeployed
    • The debugger is reattached
  7. You can now verify the changes and debug again as needed.

Get support

To submit feedback or report an issue in your IntelliJ IDE, go to Tools > Cloud Code > Help / About > Submit feedback or report an issue to report an issue on GitHub, or ask a question on Stack Overflow.