Intrinsic Functions
The GitLab lexicon provides one intrinsic function: reference(), which maps to GitLab’s !reference YAML tag.
reference() — reuse job properties
Section titled “reference() — reuse job properties”The reference() intrinsic lets you reuse properties from other jobs or hidden keys. It produces the !reference YAML tag:
import { Job, reference } from "@intentius/chant-lexicon-gitlab";
export const deployRef = new Job({ script: reference(".setup", "script"),});Serializes to:
deploy: script: !reference [.setup, script]Syntax
Section titled “Syntax”reference(jobName: string, property: string): ReferenceTagjobName— the job or hidden key to reference (e.g.".setup","build")property— the property to extract (e.g."script","before_script","rules")
Use cases
Section titled “Use cases”import { Job, reference } from "@intentius/chant-lexicon-gitlab";
// Shared setup scripts from external YAMLexport const testRef = new Job({ stage: "test", before_script: reference(".node-setup", "before_script"), script: ["npm test"],});
export const lintRef = new Job({ stage: "test", before_script: reference(".node-setup", "before_script"), script: ["npm run lint"],});
// Shared rulesexport const buildRef = new Job({ stage: "build", rules: reference(".default-rules", "rules"), script: ["npm run build"],});Produces:
test: stage: test before_script: !reference [.node-setup, before_script] script: - npm test
lint: stage: test before_script: !reference [.node-setup, before_script] script: - npm run lintWhen to use reference() vs direct imports
Section titled “When to use reference() vs direct imports”import { Job, reference } from "@intentius/chant-lexicon-gitlab";import { npmCache, testArtifacts } from "./config";
// Preferred for chant-managed config — resolved at build timeexport const testImported = new Job({ cache: npmCache, artifacts: testArtifacts, script: ["npm test"],});
// For external/included YAML definitions — produces !reference tagsexport const testExternal = new Job({ before_script: reference(".ci-setup", "before_script"), script: ["npm test"],});