feat(executor): auto-capture ADO build variables in ExecutionContext#378
Conversation
Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/814f3245-184d-4610-9c1f-f251b9825eca Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/814f3245-184d-4610-9c1f-f251b9825eca Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
|
/rust-review |
|
✅ Rust PR Reviewer completed successfully! |
🔍 Rust PR ReviewSummary: Looks good — clean refactor with solid test coverage. Two minor observations worth eyeballing before merge. Findings
|
Stage 3 executors and logs lacked structured access to ADO build vars — particularly the
BUILD_TRIGGEREDBY_*set surfaced by the pipeline-completion trigger IR — soadd_build_tagwas reaching intostd::env::vardirectly to fill the gap.Summary
ExecutionContext(src/safeoutputs/result.rs) — adds 14Option<…>fields covering build identity (build_id: Option<u64>,build_number,build_reason,definition_name,source_branch,source_branch_name,source_version),ResourceTriggerupstream context (triggered_by_build_id,triggered_by_definition_name,triggered_by_build_number,triggered_by_project_id), and PR context (pull_request_id,pull_request_source_branch,pull_request_target_branch).from_env_lookup<F>constructor —Default::default()now delegates to a generic env lookup so tests drive population from aHashMap-backed closure rather than mutating process-global env (which isunsafein Rust 2024 and the repo avoids it).add_build_tag.rs— replaces the inlinestd::env::var("BUILD_BUILDID")withctx.build_id, eliminating the last executor that read build vars directly from env.log_execution_context(src/execute.rs) — emitsbuild_id,build_reason, andtriggered_by_definition_nameso trigger source is visible in Stage 3 logs.ExecutionContext { ... }literals across the executor tests to..Default::default()so future field additions don't ripple through unrelated test files.Fields not yet read by production code carry
#[allow(dead_code)]; they're populated for executor consumers added in follow-ups. No template change is required — ADO auto-exposes allBUILD_*/SYSTEM_*predefined variables to bash steps; onlySYSTEM_ACCESSTOKEN(already wired viaexecutor_ado_env) needs explicit mapping. CLI overrides and Stage 1 exposure are intentionally deferred per the plan.Test plan
cargo build,cargo clippy --all-targets --all-features— clean (no new warnings).cargo test— 1057 passing, including 8 new tests insafeoutputs::resultcovering field population,build_idnumeric/non-numeric/absent parsing, and absenttriggered_by_*/pull_request_*fields.