When starting or restarting a workspace you typically want to run certain tasks. Most probably that includes the build and maybe also running tests and automatically start the application in e.g. a dev server.
Gitpod allows you to configure start tasks in the
For instance, the start script for the Gitpod documentation repository is defined as:
tasks: - command: mdbook serve --hostname 0.0.0.0
You can have multiple tasks, which are opened on separated terminals.
tasks: - command: echo Terminal1 - command: echo Terminal2
They are started in parallel. See belows options on configuring where and how the terminals are placed in the workbench.
command property is used to specify the command that shall be run on every start of a workspace.
It is a bash command and doesn’t need to terminate. For instance, you could start a web server or a database.
The script below will start a development-time web server in many npm projects:
tasks: - command: npm run dev
init property can be used to specify shell commands that should only be executed after a workspace was freshly cloned and needs to be initialized somehow.
Such tasks are usually builds or downloading dependencies. Anything you only want to do once but not when you restart a workspace or start a snapshot.
Here is an example for a node project that makes use of
tasks: - init: npm install command: npm run dev
This will make sure that
npm install is executed only after the repository was cloned, but not when restarting the workspace or starting a snapshot of that workspace.
In case you need to run something even before init, that is a requirement for both
command, you can use the
tasks: - before: setup.sh init: npm install command: npm run dev
Check the table below for an overview of the different starting scenarios.
prebuild command will be executed during prebuilds. It is meant to run additional
long running processes that could be useful, e.g. running test suites.
A task allows to configure where and how the terminal should open using the properties below. Please note that this information is used if no previous terminals in the layout exist. Snapshots will first try to reuse existing terminals in the layout, before opening new ones.
tasks: - command: python3 -m http.server 8080 name: Static Server - openMode: split-right command: echo SplitTerminal - openIn: left command: echo LeftPanelTerminal
You can configure where in the IDE the terminal should be opened:
||the bottom panel (default)|
||the left panel|
||the right panel|
||the main editor area|
You can configure how the terminal should be opened relative to the previous task.
||Opens in the same tab group right after the previous tab|
||Opens in the same tab group left before the previous tab|
||Splits and adds the terminal to the right|
||Splits and adds the terminal to the left|
||Splits and adds the terminal to the top|
||Splits and adds the terminal to the bottom|