Immutable Git Experience template versions
U
Umber Unicorn
Summary
A Git Experience template version should be immutable and tied to the Git commit it was published from. Today each template version needs its own YAML file in the repository, and a published version can still be changed by editing that file.
Background
We use Git as the source of truth for our templates, and we version them with semantic versioning.
Today every version of a template is its own file:
.harness/orgs/my_org/templates/my_stage_template/v1.0.0.yaml
.harness/orgs/my_org/templates/my_stage_template/v1.0.1.yaml
.harness/orgs/my_org/templates/my_stage_template/v1.1.0.yaml
- Each new version copies the whole YAML of the previous one, so the repository fills up with near-identical files, and the history of a template is spread across them.
- A published version is not immutable. Anyone can change v1.0.0.yamlon the default branch, and every pipeline that usesv1.0.0picks up the change.
Expected behaviour
- One file per template.The version label stays in the template YAML, as it is today.
- When a version is published, Harness ties it to the commit it was published from.
- That version is immutable: a pipeline that uses it always gets the template as it was in that commit.
- A change to the template that keeps the same versionLabelis rejected. Changing a template means publishing a new version.
- To release a new version, we change the template and bump versionLabelin the same file. Earlier versions stay available from their own commits.
For example, a single file:
.harness/orgs/my_org/templates/my_stage_template/template.yaml
template:
name: My Stage Template
identifier: my_stage_template
versionLabel: v1.1.0
type: Stage
spec:
...
A pipeline can then use
v1.0.0
or v1.1.0
, and each resolves to the template from its own commit.Advantages
- No duplicated YAML per version: the history of a template lives in Git, and versions can be compared with a normal diff.
- Published versions can't change underneath the pipelines that use them, so builds are reproducible.