Learn about the Gitpod CLI, a CLI tool used inside Gitpod workspaces. Also, learn about how you can use it to manage your workspaces and smooth your developer experience.
gp
) that comes installed in all workspaces and prebuilds. The gp
CLI is intended only to work inside a Gitpod workspace and is not intended to be installed on your local or other machine.
gp init
generates a default .gitpod.yml
file. You can customize it to match your requirements.
Alternatively, gp init -i
is an interactive guide which helps create the .gitpod.yml
configuration file based on a few questions you answer.
Example to start a interactive guide of .gitpod.yml
configuration file:
The gp validate
command is currently in Beta · Send feedback.
Starts a workspace within in your currently opened workspace to quickly apply and review your configuration changes. Allows you to troubleshoot your .gitpod.yml
, workspace image, ports, tasks and more. See configure workspaces for more on validating a workspace configuration.
code foo.txt
). In Gitpod, this can be done using gp open <filename>
.
We also added common aliases for gp open
: code
and open
.
Example to open the README.md
file in the current directory:
gp preview
opens a URL. The default is to show the URL in a preview pane within the editor or IDE directly. Alternatively, you can show the preview a new tab with the --external
flag.
Make sure you provide a valid URL, i.e. including the protocol. For example, http://localhost:8080.
You can also use gp preview <url> --external
to open the URL in a new browser tab.
Example opening a gitpod workspace port 3000 as a tab using gp url
and gp preview
:
gp url
provides the URL which points to a service served from a Gitpod workspace. For example gp url 8080
prints the URL which points to the service listening on port 8080 in this current workspace.
You can combine the preview
and the url
command to open a certain path instead of the default URL.
For instance:
.gitpod.yml
to open the a certain page on startup, make sure you ignore the default action when the port opens.
gp env API_ENDPOINT=https://api.example.com
you can set an API_ENDPOINT
environment variable that is accessible for this project, even if you stop the workspace and start a new one.
To delete or unset an environment variable, you use gp env -u API_ENDPOINT
.
Please refer to the help output provided by gp env --help
for more use cases of the gp env
command.
For instance, you can use following to get your all Gitpod environment variables:
gp sync-await <name>
waits until you call gp sync-done <name>
in another terminal.
See Start Tasks for a real-world example.
gp sync-await <name>
call (see previous chapter), you can call gp sync-done <name>
.
A common use case is the following where we have three terminals:
gp sync-done build
.gp sync-await build && npm run start-database
to wait for the build to complete before you start a databasegp sync-await build && npm run dev
to wait for the build to complete before you start the dev server.gp snapshot
is basically the CLI method for getting a snapshot URL. To learn more about snapshots, see Collaboration & Sharing of Workspaces
gp ssh
outputs a command you can copy/paste to another terminal to connect to your workspace via SSH. The command requires that you have uploaded a public key to Gitpod.
gp stop
is the CLI method of stopping a workspace.
Example to stop the current gitpod workspace using gitpod CLI:
Tip: You can see the task you are currently attached to highlighted in green.
gp tasks list --no-color
to disable colors for the output. It also respects the NO_COLOR
& GP_NO_COLOR
environment variable.
Terminal ID
that you can see with gp tasks list
:
Terminal ID
that you can see with gp tasks list
.
--all
flag to stop all running tasks.
Note: You can only have one workspace with extended timeout at a time.The default timeout, and the ability to extend a workspace timeout depends on your billing configuration.
m
, h
for minutes and hours, respectively. The maximum workspace timeout is 24 hours.
gp info --json
to get the output in JSON format for programmatic use in (e.g. in shell scripts).
gp ports list --no-color
to disable colors for the output. It also respects the NO_COLOR
& GP_NO_COLOR
environment variable.
0.0.0.0
and not just localhost
.
Sometimes it is not possible to make a server listen on 0.0.0.0
, e.g. because it is not your code and there are simply no means of configuration.
In that case, gp ports expose <port>
can be used to forward all traffic form a socket listing on all network interfaces to your process listening on localhost only.
gp ports await
does that.
Here’s an example that will open a certain path once a service is a available:
private
) or everyone who knows the port’s URL (public
). A port’s default visibility is always private
, unless configured differently from within .gitpod.yml
.
Here’s an example which will make port 3000
public:
3000
private:
gp ports protocol
command.
For example, to convert port 3000
to https
:
3000
to http
:
gp top --json
to get the output in JSON format for programmatic use in (e.g. in shell scripts).
gp top --no-color
to disable colors for the output. It also respects the NO_COLOR
& GP_NO_COLOR
environment variable.