cheatsheets

Gitpod

CLI Commands

gp init # Initialize a new .gitpod.yml file
gp validate # Validate the .gitpod.yml file
gp help # Get help on the CLI
gp url # Get the URL of the running workspace
gp preview $(gp url 8000)/index.html # Open the workspace in a new browser tab for path and port specified

Yaml File

# List the start up tasks. Learn more: https://www.gitpod.io/docs/configure/workspaces/tasks

# Before and init runs during prebuild => https://www.gitpod.io/docs/configure/projects/prebuilds

tasks:
  - name: Start web server
    init: python -m http.server 8000
  - name: All Tasks
    before: echo 'before script'  ## Use this for tasks that need to run before init and before command. For example, customize the terminal or install global project dependencies.
    init: echo 'init script' # Use this for heavy-lifting tasks such as downloading dependencies or compiling source code.
    command: echo 'command script' # Use this to start your database or development server
  - name: Env Task
    env:
      MYVAR: "Hello World"
    command: echo $MYVAR 
  - name: Account Env Task
    command: echo $UNIQUE_NAMESPACE 
  - name: Multiline Commmand Task
    command: |
      echo 'multiline command script 1' 
      echo 'multiline command script 2' 
  - name: Gitpod Default Env Variables
    command: |
      env | grep GITPOD_
      echo $GITPOD_WORKSPACE_URL
  - name: Await Task
    command: |
      gp sync-await tasktowaiton
      echo 'awaited for another task'
      TIMESTAMP=$(date +%Y%m%d_%H%M%S)
      echo "Timestamp: $TIMESTAMP"
  - name: Awaited Task
    command: |
      gp sync-done tasktowaiton
      echo 'awaited for this task'
      TIMESTAMP=$(date +%Y%m%d_%H%M%S)
      echo "Timestamp: $TIMESTAMP"
      sleep 1
  - name: Installed Docker Version
    command: docker version
  - name: Installed Ruby Version
    command: ruby -v
  - name: Installed Java Version
    command: java -version
  - name: Installed Go Version
    command: go version
  - name: Installed Python Version
    command: python --version
    openMode: split-left
  - name: Installed Node Version
    command: node -v
    openMode: split-left

ports:
  - port: 8000
    onOpen: open-preview

vscode:
  extensions:
    - dracula-theme.theme-dracula

Helpful