loom context
Generate GitLab pipeline context files from the current git branch.
GitLab-format runs evaluate workflow:rules and rules: against pipeline
variables that only exist on a GitLab runner. loom context init derives a
loom.gitlab-pipeline-context.v1 file from repository facts so loom check,
loom compile, and loom run can select the same jobs GitLab would, without a
hand-written JSON file.
Canonical command usage
Use the
core CLI command reference for the
exact loom context and loom context init synopsis, flags, and displayed
defaults.
loom context
loom context is a command group. Invoking it without a subcommand prints help
for the group and exits successfully. Today the group contains one subcommand:
init.
loom context init
Write .loom/contexts/<name>.json beneath the repository root.
Behavior
--as push|mris required and selects the pipeline shape to mimic.--name <name>defaults to the--asvalue. Names use letters, digits,.,_, or-(max 64 characters, no leading.).- The command fails when the file already exists unless
--forceis set. HEADmust be a branch; a detachedHEADis rejected.- The default branch is the short name of
origin/HEAD, falling back tomainwhen the remote head is unknown.
What it writes
| Field | --as push | --as mr |
|---|---|---|
CI_PIPELINE_SOURCE | push | merge_request_event |
CI_COMMIT_BRANCH | current branch | not set |
CI_COMMIT_REF_NAME | current branch | current branch |
CI_COMMIT_REF_SLUG | slug of the branch | slug of the branch |
CI_DEFAULT_BRANCH | default branch | default branch |
CI_COMMIT_SHA / CI_COMMIT_SHORT_SHA | HEAD | HEAD |
CI_COMMIT_BEFORE_SHA | first parent of HEAD, or the zero SHA | the zero SHA |
CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | not set | current branch |
CI_MERGE_REQUEST_TARGET_BRANCH_NAME | not set | default branch |
changes | base parent, head HEAD; omitted for a root commit | base default branch, head HEAD |
changes never lists paths, so rules:changes resolve through git as
described for loom check.
No runner_tags are written; add them by hand when a job requires tags.
Commit hashes are pinned at generation time. Re-run with --force after new
commits when a rule depends on CI_COMMIT_SHA or changes.
Examples
Generate a default-branch push context and run against it:
loom context init --as push --name main
loom run --local --context main
Generate a merge request context named mr:
loom context init --as mr
loom check --context mr
Short context names
--context <name> without a path separator or .json suffix resolves to
.loom/contexts/<name>.json. Any value containing / or ending in .json is
read as a project-relative path exactly as before. A missing short name fails
with the resolved path and the loom context init command that creates it.