Schema for policies

A reference for the input schema passed to the policy engine, including field descriptions, conditional fields, and example patterns.

When Octopus evaluates a policy, it passes a structured input object to the policy engine. Your Rego conditions read from this object using input.<Field> to make decisions about whether a deployment or runbook run should be allowed to proceed.

This page describes every field available in that input object, explains which fields are always present and which are conditional, and shows common patterns for using them. For complete working examples, see Policy examples.

What’s in the input object

The table below summarizes every top-level field available to your policies.

FieldTypeAlways presentDescription
EnvironmentobjectYesThe environment the deployment or runbook run is targeting
ProjectobjectYesThe project being deployed
SpaceobjectYesThe space the deployment belongs to
ProjectGroupobjectYesThe project group the project belongs to
StepsarrayYesAll steps included in the deployment process
SkippedStepsarrayYesIDs of any steps excluded from this deployment
ExecutionarrayYesExecution order and parallelism settings for each step
TenantobjectNoPresent only for tenanted deployments
ReleaseobjectNoPresent only for deployments (not runbook runs)
RunbookobjectNoPresent only for runbook runs (not deployments)

Because Tenant, Release, and Runbook are conditionally present, always check for their existence before referencing them in your conditions. For example, use input.Runbook to check the field exists before accessing input.Runbook.GitRef. See Scoping to deployments or runbook runs below.

Input fields

Environment

The environment the deployment or runbook run is targeting.

PropertyTypeDescription
IdstringThe unique identifier for the environment
NamestringThe display name of the environment
SlugstringThe URL-safe slug for the environment
Tagsarray of stringsTags applied to the environment

Example usage:

# Match environments whose slug starts with "prod"
production if {
    startswith(input.Environment.Slug, "prod")
}

# Match environments with a specific tag
input.Environment.Tags[_] == "regulated"

Project

The Octopus project where the deployment or runbook will be executed.

PropertyTypeDescription
IdstringThe unique identifier for the project
NamestringThe display name of the project
SlugstringThe URL-safe slug for the project
Tagsarray of stringsTags applied to the project

Space

The Octopus space the deployment belongs to.

PropertyTypeDescription
IdstringThe unique identifier for the space
NamestringThe display name of the space
SlugstringThe URL-safe slug for the space

ProjectGroup

The project group the project belongs to.

PropertyTypeDescription
IdstringThe unique identifier for the project group
NamestringThe display name of the project group
SlugstringThe URL-safe slug for the project group

Tenant

The tenant for tenanted deployments. This field is absent for non-tenanted deployments. Always guard against its absence before using it.

PropertyTypeDescription
IdstringThe unique identifier for the tenant
NamestringThe display name of the tenant
SlugstringThe URL-safe slug for the tenant
Tagsarray of stringsTags applied to the tenant

Example usage:

# Only evaluate for tenanted deployments
evaluate if {
    input.Tenant
}

# Check a tag on the tenant
has_required_tag if {
    some tag in input.Tenant.Tags
    startswith(tag, "tier/")
}

Steps and SkippedSteps

Steps contains every step in the deployment process. SkippedSteps contains the IDs of any steps the person creating the deployment chose to exclude.

These two fields work together. A step that’s skipped still appears in Steps, but its ID is also added to SkippedSteps. This means policies that enforce required steps need to check both fields.

Steps

PropertyTypeAlways PresentDescription
IdstringYesThe unique identifier for the step
SlugstringYesThe URL-safe slug for the step
ActionTypestringYesThe built-in action type (e.g. Octopus.Manual, Octopus.Script)
EnabledbooleanYesWhether the step is enabled in the process
IsRequiredbooleanYesWhether the step has been marked as required
SourceobjectYesWhere the step comes from. See the Source object below
PackagesarrayNoPackages referenced by this step. Not present for Runbook runs

Source object

PropertyTypeAlways PresentDescription
TypestringYesThe source type. Valid values: "Step Template", "Process Template"
SlugOrIdstringYesThe slug or ID of the step or process template
VersionstringNoThe pinned version, if one is set

Packages array

PropertyTypeAlways PresentDescription
IdstringYesThe unique identifier for the package reference
NamestringYesThe name of the package
VersionstringNoThe resolved package version
GitRefstringNoThe Git reference for the package. Originates from comes from linked Build Information

Example usage:

# Check that no steps are skipped
result := {"allowed": true} if {
    count(input.SkippedSteps) == 0
}

# Check a specific step template is present and not skipped
result := {"allowed": true} if {
    some step in input.Steps
    step.Source.Type == "Step Template"
    step.Source.SlugOrId == "<ActionTemplate-ID>"
    not step.Id in input.SkippedSteps
    step.Enabled == true
}

See the steps and skipping examples for more patterns.

Execution

The Execution array describes the order steps run in and how each step relates to the previous one. Use this field to enforce rules about parallelism or step sequencing.

PropertyTypeDescription
StartTriggerstringHow this step starts. "StartAfterPrevious" runs sequentially; "StartWithPrevious" runs in parallel with the previous step
Stepsarray of stringsThe IDs of the steps in this execution group

Example usage:

# Prevent any steps from running in parallel
result := {"allowed": true} if {
    every execution in input.Execution {
        execution.StartTrigger != "StartWithPrevious"
    }
}

Release

Details about the release being deployed. This field is absent for runbook runs.

PropertyTypeAlways PresentDescription
IdstringYesThe unique identifier for the release
NamestringYesThe release name
VersionstringYesThe release version string
GitRefstringNoThe Git reference for the release. Only present for version-controlled projects

Example usage:

# Only allow releases from the main branch
result := {"allowed": true} if {
    input.Release.GitRef == "refs/heads/main"
}

# Block releases below a minimum version in production
result := {"allowed": false, "action": "block"} if {
    production
    semver.compare(input.Release.Version, "1.0.0") < 0
}

See the release version examples for more patterns.

Runbook

Details about the runbook run. This field is absent for deployments.

PropertyTypeAlways PresentDescription
IdstringYesThe unique identifier for the runbook
NamestringYesThe display name of the runbook
SnapshotstringYesThe snapshot name used for this run
GitRefstringNoThe Git reference the runbook. Only present for version-controlled runbooks

Example usage:

# Scope a policy to runbook runs only
evaluate if {
    input.Runbook
}

# Only allow runbook runs published from main
result := {"allowed": true} if {
    input.Runbook.GitRef == "refs/heads/main"
}

Scoping to deployments or runbook runs

Because Release and Runbook are mutually exclusive, you can use them to scope a policy to one type of execution or the other.

# Deployments only
evaluate if {
    not input.Runbook
}

# Runbook runs only
evaluate if {
    input.Runbook
}

Output schema

Your Rego conditions must define a result object that Octopus reads to determine what to do. The result object supports three properties:

PropertyTypeAlways PresentDescription
allowedbooleanYesWhether the policy permits the deployment to proceed
reasonstringNoA message shown to the user when the policy fails
actionstringNoOverrides the violation action. Valid values: "block" or "warn"

The action field lets individual policy rules override the default violation action set on the policy. This is useful when you want a single policy to block in production but warn in other environments.

Example:

# Block in production, warn elsewhere
result := {"allowed": false, "action": "block"} if {
    production
    version_less_than_required
}

result := {"allowed": false} if {
    not production
    version_less_than_required
}

result := {"allowed": true} if {
    not version_less_than_required
}

Full input schema reference

The complete JSON schema for the policy input object is provided below for use with schema validation tools or IDE integrations.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Octopus Policy input schema",
  "type": "object",
  "properties": {
    "Environment": {
      "type": "object",
      "properties": {
        "Id": { "type": "string" },
        "Name": { "type": "string" },
        "Slug": { "type": "string" },
        "Tags": { "type": "array", "items": { "type": "string" } }
      },
      "required": ["Id", "Name", "Slug", "Tags"]
    },
    "Project": {
      "type": "object",
      "properties": {
        "Id": { "type": "string" },
        "Name": { "type": "string" },
        "Slug": { "type": "string" },
        "Tags": { "type": "array", "items": { "type": "string" } }
      },
      "required": ["Id", "Name", "Slug", "Tags"]
    },
    "Space": {
      "type": "object",
      "properties": {
        "Id": { "type": "string" },
        "Name": { "type": "string" },
        "Slug": { "type": "string" }
      },
      "required": ["Id", "Name", "Slug"]
    },
    "Tenant": {
      "type": "object",
      "properties": {
        "Id": { "type": "string" },
        "Name": { "type": "string" },
        "Slug": { "type": "string" },
        "Tags": { "type": "array", "items": { "type": "string" } }
      },
      "required": ["Id", "Name", "Slug", "Tags"]
    },
    "ProjectGroup": {
      "type": "object",
      "properties": {
        "Id": { "type": "string" },
        "Name": { "type": "string" },
        "Slug": { "type": "string" }
      },
      "required": ["Id", "Name", "Slug"]
    },
    "SkippedSteps": {
      "type": "array",
      "items": { "type": "string" }
    },
    "Steps": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "Id": { "type": "string" },
          "Slug": { "type": "string" },
          "ActionType": { "type": "string" },
          "Enabled": { "type": "boolean" },
          "IsRequired": { "type": "boolean" },
          "Source": {
            "type": "object",
            "properties": {
              "Type": { "type": "string" },
              "SlugOrId": { "type": "string" },
              "Version": { "type": "string" }
            },
            "required": ["Type", "SlugOrId"]
          },
          "Packages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "Id": { "type": "string" },
                "Name": { "type": "string" },
                "Version": { "type": "string" },
                "GitRef": { "type": "string" }
              },
              "required": ["Id", "Name"]
            }
          }
        },
        "required": ["Id", "Slug", "ActionType", "Enabled", "IsRequired", "Source"]
      }
    },
    "Release": {
      "type": "object",
      "properties": {
        "Id": { "type": "string" },
        "Name": { "type": "string" },
        "Version": { "type": "string" },
        "GitRef": { "type": "string" }
      },
      "required": ["Id", "Name", "Version"]
    },
    "Runbook": {
      "type": "object",
      "properties": {
        "Id": { "type": "string" },
        "Name": { "type": "string" },
        "Snapshot": { "type": "string" },
        "GitRef": { "type": "string" }
      },
      "required": ["Id", "Name", "Snapshot"]
    },
    "Execution": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "StartTrigger": { "type": "string" },
          "Steps": { "type": "array", "items": { "type": "string" } }
        },
        "required": ["StartTrigger", "Steps"]
      }
    }
  },
  "required": [
    "Environment",
    "Project",
    "Space",
    "SkippedSteps",
    "Steps",
    "ProjectGroup",
    "Execution"
  ]
}

Help us continuously improve

Please let us know if you have any feedback about this page.

Send feedback

Page updated on Thursday, September 11, 2025

Use Octopus docs with AI