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
| Field | Type | Required | Description |
|---|
name | string | Yes | Display name shown in UI and logs |
description | string | No | Description of what the service does |
commands | object | No | Lifecycle commands (see below) |
triggeredBy | array | No | When to automatically start (see Triggers) |
runsOn | object | No | Execution environment (see Execution environment) |
role | string | No | Service role: default, editor, or ai-agent |
Service commands
The commands object controls the service lifecycle:
| Field | Required | Description |
|---|
start | Yes (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. |
ready | No | Readiness check command. Runs repeatedly until it exits with code 0. Service stays in Starting phase until ready succeeds. |
stop | No | Custom 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:
| Phase | Description |
|---|
STARTING | Start command running, readiness check pending (if configured) |
RUNNING | Service is running and ready |
STOPPING | Service is being stopped |
STOPPED | Service stopped normally (exit code 0) |
FAILED | Service failed (non-zero exit code) |
Task schema
Tasks are one-off actions that run to completion.
Task fields
| Field | Type | Required | Description |
|---|
name | string | Yes | Display name shown in UI and logs |
command | string | Yes | Shell command to execute |
description | string | No | Description of what the task does |
triggeredBy | array | No | When to automatically run (see Triggers) |
dependsOn | array | No | Task keys that must complete before this task starts |
runsOn | object | No | Execution 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:
| Phase | Description |
|---|
PENDING | Task waiting to start |
RUNNING | Task is executing |
SUCCEEDED | Task completed successfully (exit code 0) |
FAILED | Task failed (non-zero exit code) |
STOPPED | Task was stopped before completion |
Triggers
Control when tasks and services run automatically:
| Trigger | Services | Tasks | Description |
|---|
manual | ✓ | ✓ | Triggered by explicit user action via CLI or UI |
postDevcontainerStart | ✓ | ✓ | After container starts (first start or rebuild) |
postEnvironmentStart | ✓ | ✓ | Every time the environment starts or resumes |
prebuild | ✗ | ✓ | During 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
| Field | Type | Required | Description |
|---|
docker.image | string | Yes | Docker image to use |
docker.environment | array | No | Environment 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]
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