Open in Cloud Shell

The Open in Cloud Shell feature allows you to publish a link that opens the Google Cloud console with a Git repository cloned into Cloud Shell and/or starts Cloud Shell with a custom image. You can also print instructions to the terminal to help users interact with the content.

Open in Cloud Shell links help developers experiment with your code samples and APIs without having to download the Google Cloud CLI, install required dependencies, or search for relevant source files. This page explains how to add an Open in Cloud Shell link to your Git repository.

URL parameters

An Open in Cloud Shell link, optionally embedded in a button image, can be added to the README.md file of any directory in your Git repository. The recommended location for this link is the root README.md file of your Git repository.

Required URL parameter

To create this link, use a base URL of shell.cloud.google.com (or any page in the Google Cloud console that begins with console.cloud.google.com) with the following required URL parameter:

URL Parameter Description Supported Values
cloudshell_git_repo

URL of the Git repository to clone.

After the repository is cloned, the root of the project folder is opened, displaying its contents in the left navigation pane.

Valid URL for a Git repository.

This URL consists of a permitted domain (GitHub or Bitbucket) and a path. The following characters are permitted: uppercase and lowercase letters, digits, underscores (_), hyphens (-), periods (.), and forward-slashes (/).

Optional URL parameters

You can also specify any of the following optional parameters:

URL Parameter Description Supported Values
cloudshell_git_branch Branch from the Git repository to clone. Only applicable when cloudshell_git_repo is specified. The default branch is master. Any valid branch in the repository. The following characters are permitted: uppercase and lowercase letters, digits, tildes (~), underscores (_), hyphens (-), periods (.), forward-slashes (/), and colons (:).
cloudshell_image

Custom Docker image that runs a customized environment during the session. This allows you to provide custom tooling in Cloud Shell that users can use to work with your repository.

Opening a repository in Cloud Shell with this parameter specified creates a temporary environment with a scratch home directory that is deleted when the session ends.

URL of a Docker image hosted in Container Registry. The Docker image must be based on the base Cloud Shell image and be publicly accessible.

To create a valid image, use the custom image creation tutorial that can be started by running the following command in Cloud Shell:

cloudshell launch-tutorial /google/devshell/tutorials/custom-image-tutorial.md

Note that large images take some time to download to the Cloud Shell VM when the URL is opened.

cloudshell_open_in_editor

File(s) to open in Cloud Shell Editor. Can be repeated to specify multiple files to open. If multiple are specified, they are be opened in the order provided.

Specified file(s) are opened in the right hand editor tabs, one tab per file, in the opened project.

File paths are relative to the current directory. If the working_dir param is provided, the path to these files is treated as relative to working_dir.

Any valid file path that consists of the following permitted characters: uppercase and lowercase letters, digits, tildes (~), underscores (_), hyphens (-), periods (.), forward slashes (/), and colons (:).
cloudshell_print

File in the Git repository, usually consisting of instructions to be printed to the terminal to guide a user's next steps. The file path is relative to the current directory.

If the working_dir param is provided, the path to this file is treated as relative to working_dir.

Any valid file path that consists of the following permitted characters: uppercase and lowercase letters, digits, tildes (~), underscores (_), hyphens (-), periods (.), forward slashes (/), and colons (:).
cloudshell_tutorial

Tutorial Markdown file in the Git repository consisting of instructions to be launched as a tutorial to guide users through a project. The file path is relative to the current directory.

Any well-formed Tutorial Markdown file with a valid filename.

cloudshell_working_dir (Deprecated)

This parameter is deprecated. Use cloudshell_workspace instead.

Any valid file path that consists of the following permitted characters: uppercase and lowercase letters, digits, tildes (~), underscores (_), hyphens (-), periods (.), forward slashes (/), and colons (:).
cloudshell_workspace Working directory for Cloud Shell. The terminal opens in the specified directory. Cloud Shell Editor opens the directory as a workspace. Any valid file path relative to the cloned repository. You can leave the parameter value empty or use . to specify the root of the cloned repository. If no repository is specified, the path is relative to the Cloud Shell home directory. The following characters are permitted: uppercase and lowercase letters, digits, tildes (~), underscores (_), hyphens (-), periods (.), forward slashes (/), and colons (:).
ephemeral Opening a repository in Cloud Shell with this parameter specified creates a temporary environment with a scratch home directory that is deleted when the session ends. For more information, see Choosing ephemeral mode.

true, false

show

Open with just the terminal, just the Cloud Shell Editor, or both.

ide, terminal, ide%2Cterminal

Examples

To embed a button to open a sample Git repository in Cloud Shell, include the following Markdown in your repository's README.md file:

  [![Open in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.svg)](https://shell.cloud.google.com/cloudshell/editor?cloudshell_git_repo=http://path-to-repo/sample.git)

To embed the same functionality into a website, use this equivalent HTML snippet:

  <a href="https://shell.cloud.google.com/cloudshell/editor?cloudshell_git_repo=http://path-to-repo/sample.git">
  <img alt="Open in Cloud Shell" src ="https://gstatic.com/cloudssh/images/open-btn.svg">
  </a>

To define the behavior of the Open in Cloud Shell link more specifically, you can use the form below to experiment with parameters needed to open your repository in Cloud Shell.