Jobs

What is a job?

A job is an arbitrary task that SaturnCI runs in a Docker container. Jobs can be used for deployments, database migrations, or any other scripted task you want to run in a reproducible environment.

Setting up a job

To set up a job, create a directory at .saturnci/jobs/<job-name>/ in your repository with three files:

  • Dockerfile — the Docker image for the job
  • docker-compose.yml — the Docker Compose configuration
  • run — the script that gets executed

Make sure the run script is executable (chmod +x .saturnci/jobs/<job-name>/run).

Example: a deployment job

.saturnci/jobs/deploy/Dockerfile:

FROM ubuntu:24.04

RUN apt-get update && apt-get install -y \
  curl \
  && rm -rf /var/lib/apt/lists/*

# Install kubectl
RUN curl -sLO "https://dl.k8s.io/release/v1.31.0/bin/linux/amd64/kubectl" \
  && chmod +x kubectl && mv kubectl /usr/local/bin/

.saturnci/jobs/deploy/docker-compose.yml:

services:
  job:
    build:
      context: ../../..
      dockerfile: .saturnci/jobs/deploy/Dockerfile
    volumes:
      - ../../../:/app
    working_dir: /app

.saturnci/jobs/deploy/run:

#!/bin/bash

echo "Deploying $CONTAINER_IMAGE_URL..."
kubectl set image deployment/myapp myapp=$CONTAINER_IMAGE_URL
kubectl rollout status deployment/myapp
echo "Deploy complete!"

The CONTAINER_IMAGE_URL environment variable is automatically available when the job is triggered with a container image URL via the SaturnCI SDK.