Open in Cloud Shell

The Open in Cloud Shell feature allows you to publish a link that opens the Cloud Console and either automatically clones a Git repository into Cloud Shell or starts Cloud Shell with a custom image. It also allows for instructions to be printed to the terminal to help users interact with the content.

The Open in Cloud Shell feature helps developers experiment with code samples and APIs without having to worry about downloading Cloud SDK, installing required dependencies, or searching for relevant source files. This page explains how to add this feature to your Git repository.

Currently, only GitHub and Bitbucket repositories are whitelisted. If you would like to add a different repository, send feedback with the repository type you'd like to use with Open in Cloud Shell.

URL parameters

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

To add functionality to this Open in Cloud Shell interaction, you'll have to you'll have to use a base URL of ssh.cloud.google.com (or any page in the Cloud Console that begins with console.cloud.google.com) with at least one of these two URL parameters:

URL Parameter Description Supported Values
cloudshell_git_repo

URL of the Git repository to clone.

The specified repository will be cloned and the root of the project folder will be opened, displaying its contents in the left hand navigation pane.

Valid URL for a Git repository.

This consists of a whitelisted domain (GitHub or Bitbucket) and a path composed with these valid characters [a-zA-Z0-9_-./].

cloudshell_image

Specifies custom Docker image that runs a custom environment during the session. This allows you to provide custom tooling in Cloud Shell for working with your repository. Note that this creates a temporary environment with a scratch home directory that will be deleted on session end.

URL of a Docker image hosted in Google Container Registry. The Docker image must be based off the base Cloud Shell image.

Additionally, you can specify any of these optional parameters:

URL Parameter Description Supported Values

cloudshell_git_branch

The specific 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. Characters must match this whitelist: [a-zA-Z0-9~_-./:]

cloudshell_working_dir

Working directory to land the user in on the command line. Any valid file path. Characters must match this whitelist: [a-zA-Z0-9~_-./:]

cloudshell_open_in_editor

File(s) to be opened in the integrated Theia editor. Can be repeated to specify multiple files to open. If multiple are specified, they will be opened in the order provided.

Specified file(s) will be 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 will be treated as relative to working_dir.

Any valid file path. Characters must match this whitelist: [a-zA-Z0-9~_-./:]

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 will be treated as relative to working_dir.

Any valid file path. Characters must match this whitelist: [a-zA-Z0-9~_-./:]

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.

Examples

To provide a link to open a sample Git repository in Cloud Shell, you would need to use Markdown such as the following snippet to embed the link in your repository's README.md:

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

If you'd rather embed this functionality into a website, the HTML equivalent to the above snippet:

<a href="https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=http://path-to-repo/sample.git"><img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.svg"></a>
Оцените, насколько информация на этой странице была вам полезна:

Оставить отзыв о...

Текущей странице