Skip to main content
An environment policy is a YAML file that declares compliance requirements for artifacts running in a Kosli environment. You pass the file to kosli create policy to create or update a policy. For concepts, workflow, and enforcement, see Environment Policies.
Prefer to build a policy interactively? Use the Policy builder to assemble a valid policy file in your browser and copy the YAML.

Specification

_schema
string
required
Version identifier and JSON Schema URL for the policy format. The final path segment must match /v{n} where n is a supported major version. Currently only v1 is supported.
artifacts
object
Rules applied to artifacts in an environment snapshot. Omitted keys use server defaults.

Attestation types

ValueDescription
genericGeneric attestation
junitJUnit test results
snykSnyk security scan
pull_requestPull request evidence
jiraJira ticket reference
sonarSonarQube analysis
*Matches any built-in or custom type
custom:<name>A custom attestation type (e.g., custom:coverage-metrics)

Policy expressions

Expressions are boolean conditions evaluated against flow and artifact context. They are wrapped in ${{ }} and can appear in if and exceptions[].if fields.

Operators

OperatorCategoryExample
==Comparisonflow.name == "runner"
!=Comparisonflow.tags.risk-level != "high"
<Comparisonflow.tags.priority < 3
>Comparisonflow.tags.priority > 1
<=Comparisonflow.tags.risk-level <= 2
>=Comparisonflow.tags.risk-level >= 2
andLogicalflow.name == "a" and artifact.name == "b"
orLogicalflow.name == "a" or flow.name == "b"
notLogicalnot flow.tags.risk-level == "high"
inMembershipflow.name in ["runner", "saver"]
Parentheses control precedence: ${{ flow.name == 'prod' and (flow.tags.team == "a" or artifact.name == 'svc') }}.

Contexts

flow
object
Information about the Kosli flow the artifact belongs to.
artifact
object
Information about the artifact being evaluated.

Functions

FunctionDescriptionExample
exists(arg)Returns true if arg is not null.${{ exists(flow) }}
matches(input, regex)Returns true if input matches the regular expression.${{ matches(artifact.name, "^datadog:.*") }}

Constraints

  • _schema is the only required field. All other fields are optional and use server defaults when omitted.
  • An attestation rule must not have both name and type set to *.
  • Expressions must evaluate to a boolean. An invalid expression causes a policy evaluation error.

Example

Editor validation

The _schema URL resolves to a JSON Schema for the environment policy format. To enable inline validation and autocomplete in VS Code (requires the YAML extension) and other schema-aware editors, add a yaml-language-server directive:

See also

Last modified on June 16, 2026