Skip to main content
Ona loads tasks and services from .ona/automations.yaml in your repository root. You can change this location in Projects.
services:
  # long-running processes (databases, servers)

tasks:
  # one-off actions (build, test, seed)
The key (e.g., database, buildAll) is used to reference the item in dependencies and CLI commands. Keys must match the pattern ^[a-zA-Z0-9_-]{1,128}$ (alphanumeric, underscores, and hyphens, 1-128 characters).

Service schema

Services are long-running processes that stay active throughout your session.

Service fields

FieldTypeRequiredDescription
namestringYesDisplay name shown in UI and logs
descriptionstringNoDescription of what the service does
commandsobjectNoLifecycle commands (see below)
triggeredByarrayNoWhen to automatically start (see Triggers)
runsOnobjectNoExecution environment (see Execution environment)
rolestringNoService role: default, editor, or ai-agent

Service commands

The commands object controls the service lifecycle:
FieldRequiredDescription
startYes (if commands defined)Command to start and run the service. If it exits with code 0, service transitions to Stopped. Non-zero exit transitions to Failed.
readyNoReadiness check command. Runs repeatedly until it exits with code 0. Service stays in Starting phase until ready succeeds.
stopNoCustom stop command. If not set, start receives SIGTERM when stop is requested. If set, stop runs first, then start receives SIGKILL.
When stopping a service, if the process doesn’t exit within 2 minutes, SIGKILL is sent automatically.

Service example

services:
  database:
    name: PostgreSQL
    description: The backend database
    triggeredBy:
      - postEnvironmentStart
    commands:
      start: docker run --rm -t --name database postgres:latest
      ready: pg_isready -h localhost
      stop: docker stop database

  backend:
    name: Application Backend
    description: The application backend
    role: default
    triggeredBy:
      - postEnvironmentStart
    commands:
      start: cd backend && go run main.go

Service phases

Services transition through these phases during their lifecycle:
PhaseDescription
STARTINGStart command running, readiness check pending (if configured)
RUNNINGService is running and ready
STOPPINGService is being stopped
STOPPEDService stopped normally (exit code 0)
FAILEDService failed (non-zero exit code)

Task schema

Tasks are one-off actions that run to completion.

Task fields

FieldTypeRequiredDescription
namestringYesDisplay name shown in UI and logs
commandstringYesShell command to execute
descriptionstringNoDescription of what the task does
triggeredByarrayNoWhen to automatically run (see Triggers)
dependsOnarrayNoTask keys that must complete before this task starts
runsOnobjectNoExecution environment (see Execution environment)

Task example

tasks:
  buildAll:
    name: Build All
    description: Builds all code
    command: go build .

  runUnitTests:
    name: Run unit tests
    command: go test -v ./...
    dependsOn:
      - buildAll

  validate:
    name: Validate
    description: Builds and tests the code
    triggeredBy:
      - postEnvironmentStart
    dependsOn:
      - buildAll
      - runUnitTests
    command: echo "Validation complete"

Task execution phases

Task executions transition through these phases:
PhaseDescription
PENDINGTask waiting to start
RUNNINGTask is executing
SUCCEEDEDTask completed successfully (exit code 0)
FAILEDTask failed (non-zero exit code)
STOPPEDTask was stopped before completion

Triggers

Control when tasks and services run automatically:
TriggerServicesTasksDescription
manualTriggered by explicit user action via CLI or UI
postDevcontainerStartAfter container starts (first start or rebuild)
postEnvironmentStartEvery time the environment starts or resumes
prebuildDuring prebuild execution (no user secrets available)
prebuild is only valid for tasks. User secrets are not available during prebuild execution.

Execution environment

By default, commands run directly on the VM. Use runsOn to run in a container instead:

Run on machine (default)

services:
  backend:
    name: Backend
    runsOn:
      machine: {}
    commands:
      start: go run main.go

Run in Docker container

services:
  redis:
    name: Redis Server
    runsOn:
      docker:
        image: redis:7
        environment:
          - REDIS_PORT=6379
    commands:
      start: redis-server
      ready: redis-cli ping
FieldTypeRequiredDescription
docker.imagestringYesDocker image to use
docker.environmentarrayNoEnvironment variables passed to the container (format: VAR=value)
For environment-wide secrets and variables, see Secrets.

Complete example

This example demonstrates all available schema features:
services:
  # Service running in a Docker container with all lifecycle commands
  redis:
    name: Redis Cache
    description: In-memory cache for session data
    role: default
    triggeredBy:
      - postDevcontainerStart
    runsOn:
      docker:
        image: redis:7-alpine
        environment:
          - REDIS_PORT=6379
    commands:
      start: redis-server --appendonly yes
      ready: redis-cli ping | grep -q PONG
      stop: redis-cli shutdown

  # Service running directly on the VM
  backend:
    name: API Server
    description: Main application backend
    triggeredBy:
      - postDevcontainerStart
      - manual
    commands:
      start: cd backend && go run main.go
      ready: curl -sf http://localhost:8080/health

  # AI agent service
  code-assistant:
    name: Code Assistant
    description: AI-powered code analysis
    role: ai-agent
    triggeredBy:
      - manual
    commands:
      start: ./bin/assistant serve

tasks:
  # Task that runs during prebuild (no user secrets available)
  install-deps:
    name: Install dependencies
    description: Install all project dependencies
    triggeredBy:
      - prebuild
      - postDevcontainerStart
    command: npm ci && go mod download

  # Task with dependencies on other tasks
  build:
    name: Build project
    description: Compile all source code
    dependsOn:
      - install-deps
    command: npm run build && go build ./...

  # Task running in a specific container
  lint:
    name: Lint code
    description: Run linters in isolated environment
    runsOn:
      docker:
        image: golangci/golangci-lint:latest
    command: golangci-lint run ./...

  # Manual task for running tests
  test:
    name: Run tests
    description: Execute the full test suite
    triggeredBy:
      - manual
    dependsOn:
      - build
    command: npm test && go test -v ./...

Iterating on Tasks and Services

You can iterate on tasks and services using the CLI which is available by default in every Ona environment. The CLI can
  • reload the tasks and services file using:
gitpod automations update [optional-path-to-automations.yaml]
  • start a task or service:
gitpod automations service start ...
gitpod automations task start ...

Using Tasks and Services outside of an environment

The CLI commands to interact with an environment’s tasks and services are also available outside of an environment. The following snippet brings up an environment, adds a task, runs it, waits for the task to complete and brings the environment back down again:
# gitpod env create will set the environment context to the newly created env
gitpod env create https://github.com/some/repo

# add the task to the environment
cat <<EOF | gitpod automations update -
tasks:
  build:
    command: go build ./...
EOF

# run it
gitpod automations task start build

# stop the environment
gitpod env stop