Skip to main content

CREATE AND RUN A WORKFLOW

Prerequisites: Swamp installed, a repository with at least one model. If you need a model first, see Create and Run a Model.

Create a workflow

swamp workflow create deploy-pipeline
Created: deploy-pipeline
Path: workflows/workflow-<uuid>.yaml

Jobs:
  main - Main job (edit or replace)
    Steps:
      example (model_method) - Example step (edit or replace)

This writes a scaffold YAML file under workflows/.

Edit the workflow definition

Open the generated file and replace the placeholder step with your model. A minimal workflow with one step:

id: <uuid>
name: deploy-pipeline
tags: {}
jobs:
  - name: main
    description: Run the greeter
    steps:
      - name: greet
        description: Say hello
        task:
          type: model_method
          modelIdOrName: my-greeter
          methodName: execute
          inputs:
            run: "echo Deploying..."
        dependsOn: []
        weight: 0
        allowFailure: false
    dependsOn: []
    weight: 0
version: 1

For the full YAML schema, see the workflows reference.

Validate the workflow

swamp workflow validate deploy-pipeline
Validating: deploy-pipeline
  ✓ Schema validation
  ✓ Unique job names
  ✓ Unique step names in job 'main'
  ✓ Valid job dependency references
  ✓ Valid step dependency references in job 'main'
  ✓ No cyclic job dependencies
  ✓ No cyclic step dependencies in job 'main'
  ✓ Step inputs for 'greet' in job 'main' (my-greeter.execute)
  ✓ GlobalArgument input references for 'greet' in job 'main' (my-greeter.execute)
Summary: 9 passed
Result: PASSED

Validation checks schema, naming, dependency cycles, and that referenced models and methods exist.

Run the workflow

For scripted or CI use, pass --json:

swamp workflow run deploy-pipeline --json
{
  "workflowName": "deploy-pipeline",
  "status": "succeeded",
  "jobs": [
    {
      "name": "main",
      "status": "succeeded",
      "steps": [
        {
          "name": "greet",
          "status": "succeeded",
          "duration": 23
        }
      ]
    }
  ],
  "duration": 28
}

Pass inputs at run time

If your workflow defines an inputs schema, supply values with --input:

swamp workflow run deploy-pipeline --input env=staging

You can also load inputs from a YAML file:

swamp workflow run deploy-pipeline --input-file params.yaml

View run history

To see the most recent run:

swamp workflow history deploy-pipeline
Workflow: "deploy-pipeline" (Run ID: "<uuid>")
  ✓ main (24ms)
    ✓ greet (23ms)
Result: SUCCEEDED (28ms)

To search past runs:

swamp workflow history search deploy-pipeline

For approval gates, see Gate a Workflow with Manual Approval.