feat(compile): support Azure DevOps variable group imports#1426
Conversation
Add a source-level `variable-groups:` front-matter list so generated pipeline locks can import project-level ADO Library variable groups (e.g. a Key Vault-backed GitHub App private key) without hand-patching the lock. Each entry emits a top-level `variables:` `- group: <name>` import, in declaration order. - IR: model `- group:` imports via a `PipelineVar` enum + lowering. - Front matter: new `variable-groups: Vec<String>` field. - Validation: group names are references only (reject injection/values); `target: job` / `target: stage` reject the feature with a clear compile-time error (templates cannot carry pipeline-level variables). - Wire standalone + 1ES builders to emit the imports. - Docs: front-matter.md, engine.md, targets.md, authoring prompt. Only group names are ever handled; values are never resolved, logged, or serialised. Follow-up #1416 tracks hyphenated private-key names. Closes #1385 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔍 Rust PR ReviewSummary: Looks good overall — clean design, correct security validation, proper YAML lowering. Three minor findings worth noting before merge. Findings
|
|
@copilot implement suggestions |
- Remove redundant `contains_newline` check from `is_valid_variable_group_name`
(control char check already subsumes newlines); update doc comment to say
"control characters (including newlines)" instead of listing them separately.
- Fix `docs/front-matter.md` rejection list to include the compiler's own
template marker (`{{`) that the validator also rejects.
- Promote `variable_group_vars` to `compile/common.rs` so `standalone_ir.rs`
and `onees_ir.rs` both use the same shared helper instead of one having a
named helper and the other inlining the equivalent chain.
- The integration-level `variable_groups_rejected_for_stage_target` test was
already present in the original commit; no further change needed there.
Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
Done in
|
|
/rust-review |
|
✅ Rust PR Reviewer completed successfully! |
🔍 Rust PR ReviewSummary: One real regression bundled with an otherwise clean feature — needs a fix before merge. Findings🐛 Bugs / Logic Issues
|
Address Rust PR Reviewer feedback: variable-groups: [A, A] previously passed validation and emitted two redundant '- group: A' entries whose ADO collision behaviour is unspecified. validate_variable_groups now fails closed on duplicates (case-insensitive, whitespace-trimmed, matching ADO's case-insensitive group names). Docs updated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed the latest Rust PR Reviewer round in Duplicate group names (suggestion) — fixed.
|
🔍 Rust PR ReviewSummary: Looks good overall — solid validation design, correct lowering, and good test coverage. One validation gap worth closing before merge. Findings
|
Address Rust PR Reviewer feedback: - is_valid_variable_group_name now rejects names with leading/trailing whitespace (name == name.trim()); previously a padded entry like ' Shared Secrets ' passed and was emitted verbatim into the YAML, risking an unspecified ADO runtime group lookup. - lower_variables_emits_group_imports_in_order now also asserts group entries carry no name key (via '- name:' item form, avoiding a false collision with the top-level pipeline 'name:' key). - Updated tests and docs accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed the latest Rust PR Reviewer round in Leading/trailing whitespace in group names (suggestion) — fixed. Missing
|
🔍 Rust PR ReviewSummary: Looks good — clean design, strong security validation, and good test coverage. Two minor items worth addressing. Findings
|
Address Rust PR Reviewer feedback: - validate_variable_groups duplicate key drops the now-redundant .trim() (is_valid_variable_group_name already rejects padded names), and the comment/error no longer claim whitespace normalisation. - docs/ir.md and site IR reference now document the PipelineVar enum (NameValue / Group) introduced by this PR, which was previously undocumented. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed the latest Rust PR Reviewer round in Redundant Stale
|
🔍 Rust PR ReviewSummary: Looks good — all findings from previous rounds have been correctly addressed; the code is in clean shape for merge. Findings✅ What Looks Good
|
… reference Add the variable-groups: front-matter field (introduced in #1426) to the human-facing docs: - README.md front matter fields table: new row after repos: - site/src/content/docs/reference/front-matter.mdx: - Overview YAML block: add variable-groups: commented entry after repos: - New ## Variable Groups section (authorization, names-only, target support) Verified: cd site && npm run build:astro — 38 pages, all internal links valid. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The feat(compile): variable-groups front-matter field (#1426) updated the create prompt (Step 17b) but not the update prompt. This left agents that use the update prompt without guidance on how to add or manage variable groups in existing workflows. Add three things to prompts/update-ado-agentic-workflow.md: 1. Add `variable-groups` to the conventional field order list in Step 2 (after `supply-chain`, before `parameters`). 2. Add an "Adding Variable Groups" scenario in the Common Update Scenarios section with usage notes and a link to docs/front-matter.md. 3. Add a new checklist item (8) for variable-groups target compatibility: the field is only valid on standalone / 1es and is a compile-time error on job / stage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… reference (#1434) Add the variable-groups: front-matter field (introduced in #1426) to the human-facing docs: - README.md front matter fields table: new row after repos: - site/src/content/docs/reference/front-matter.mdx: - Overview YAML block: add variable-groups: commented entry after repos: - New ## Variable Groups section (authorization, names-only, target support) Verified: cd site && npm run build:astro — 38 pages, all internal links valid. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Adds source-level support for Azure DevOps variable group imports so generated pipeline locks can consume project-level (often Key Vault-backed) secrets — such as a shared GitHub App private key — without hand-editing the generated YAML.
A new front-matter list declares the imports:
which compiles to a top-level import per entry, in declaration order:
Why
In Azure DevOps, a variable group being authorized for a pipeline definition is not enough — the YAML must also explicitly import the group. ado-aw already lets
engine.github-app-token.private-keyreference an ADO secret variable and emits$(NAME)macros, but never imported the group, so a source-clean lock could not consume a project-level secret without hand-patching (which breaks lock integrity). This PR provides the missing YAML import.Changes
compile/ir/mod.rs,compile/ir/lower.rs):PipelineVaris now an enum modelling- group:imports alongside literal- name/valueentries, with matching lowering.compile/types.rs): newvariable-groups: Vec<String>field.compile/common.rs+validate.rs, wired at the sharedbuild_pipeline_contextchokepoint): group names are validated as safe references (reject$(,$[,${{,##vso[,##[, control characters, newlines); a non-emptyvariable-groups:ontarget: job/target: stageis a hard compile-time error (ADO templates cannot carry pipeline-levelvariables:— the parent pipeline owns them). Names with leading/trailing whitespace, and duplicate imports (case-insensitive), are also rejected — padded names are emitted verbatim, and ADO group names are case-insensitive and a repeated- group:has unspecified collision behaviour.compile/standalone_ir.rs,compile/onees_ir.rs): emit the imports at the pipeline root (valid alongside the 1ESextends:block).docs/front-matter.md,docs/engine.md,docs/targets.md, and the authoring promptprompts/create-ado-agentic-workflow.md.Security
$(VAR_NAME)).Design decisions
variable-groups:list (rather than ADO-nativevariables: - group:), to avoid a future collision with literal name/valuevariables:support. The list handles multiple groups natively.Testing
cargo check✓,cargo clippy --all-targets --all-features✓ (clean)github-app-token+ variable group compiling without a lock patch)Follow-up
private-keynames (Key Vault-backed groups commonly expose hyphenated secret names), recommending a dedicated ADO-variable-name validator.Closes #1385