Prerequisites: Complete Lab 3: Build Controls before starting this lab.
Learning goals
- Understand Flow Templates and how they define compliance requirements
- Update an existing Flow to enforce specific attestations
- Understand the difference between compliant and non-compliant Trails
- Use
kosli assert artifactto gate deployments based on compliance status
Introduction
In the previous labs, you’ve been recording evidence (attestations) for your builds. However, recording evidence is only half the picture — you also need to ensure the required evidence is actually present before allowing a release. Flow Templates define the “shape” of a compliant release. They specify:- Which artifacts are expected in the Trail
- Which attestations are required for each artifact
- Which attestations are required at the Trail level
kosli assert artifact to your pipeline, you can automatically block deployments that don’t meet your compliance standards.
See Flow Templates for the full template specification.
Exercise
Define compliance requirements
Create a file named This template matches the attestations you set up in Lab 3:
flow-template.yaml in the root of your repository:- An
applicationartifact that must haveunit-tests - A
docker-imageartifact that must have ansbom
Update the Flow to use the template
In
.github/workflows/full-pipeline.yaml, find the Create/Update Flow step (added in Lab 2) and replace --use-empty-template with --template-file:Gate the release
In the This command asks Kosli: “Is this artifact and its Trail compliant?”
Deploy job, add the following steps before the “Deploy to production” step:- Compliant (all required attestations present and none failing): exits
0— pipeline continues to deploy - Non-compliant (missing or failing attestations): exits
1— pipeline fails, deployment is blocked
kosli assert artifact for full flag reference.Push and test the gate
Assert compliance step should pass (green).Then in app.kosli.com, navigate to your Flow → latest Trail. The Compliance status should show Compliant with all template requirements checked off.Optional: test non-compliance
Optional: test non-compliance
To see the gate in action, add a non-existent attestation requirement to Commit and push. The
flow-template.yaml:Assert compliance step should fail, preventing the deploy step from running. The Trail in Kosli will be marked Non-compliant.Verification checklist
-
flow-template.yamlcreated in repository root - Workflow updated to apply the template
-
kosli assert artifactadded to the Deploy job - A fully attested build passes the compliance gate
- Trail shows as Compliant in the Kosli web interface
If anything didn’t go to plan, refer to the reference solution at
pipelines/04-complete.yaml in the labs repository.