Drives the full promotion workflow in DevOps Center — validate, prepare, optionally combine, promote, and complete — moving work items through the release pipeline. Provides headless,
-driven, idempotent operations for autonomous release workflows in CI. Every promotion begins with a mandatory validate step.
If the user gives a clear request ("promote work item 1fkxx… to stage 1QVxx…", "promote the QA stage to UAT", "combine these work items and promote"), proceed once you have the required IDs.
All operations use
CLI commands with
output. Validate ALWAYS runs first. All promotion commands are keyed on
record IDs, not work item names — resolve names to IDs first if needed.
-
Verify org authentication before any operation:
- If it fails, instruct the user to run
sf org login web --set-default --alias <alias>
- Pass on every subsequent command (required unless the config variable is set)
-
Run the mandatory validate step — this is non-negotiable and always runs before prepare/combine/promote.
sf devops promotion validate
requires the target stage (
) and one or more
:
bash
# Capture the output — Phase 2 derives the combine decision from it deterministically.
VALIDATE_JSON=$(sf devops promotion validate --work-item-id <id> --target-stage-id <target-stage-id> --target-org <alias> --json)
- Validates whether the work item(s) can be promoted to the target stage — checks for VCS and object-permission errors (including the associated-PR requirement) before a promotion is attempted
- Repeat to validate multiple work items in one call
- Success: and — proceed
- If validation fails (non-zero exit; e.g.
VCS_ERROR: No pull request exists…
, with / set), STOP. Report the error and do not proceed. If it references metadata overlap, resolve the conflict before retrying
- Shared components: when is non-null, the work items share metadata — validate returns the parent/child grouping and . This is the authoritative signal for the Phase 2 combine decision (see step 4); do not guess whether to combine — the Phase 2 script reads from
-
Prepare the work item for promotion:
bash
sf devops work-item prepare --work-item-id <id> --target-stage-id <target-stage-id> --target-org <alias> --json
- is required — the same target stage the work item will be promoted to
- Idempotent: re-running a prepared work item is safe — treat as success
-
Combine work items — ONLY when the Phase 1 validate step reported shared components (
non-null) or the work items otherwise have dependencies and must promote as one unit. Do not eyeball the JSON — derive the decision and the parent/child IDs deterministically from the saved validate output (
):
bash
# COMBINE == "true" only when validate returned a combineDetails block.
COMBINE=$(printf '%s' "$VALIDATE_JSON" | jq -r '(.result.combineDetails != null)')
if [ "$COMBINE" = "true" ]; then
PARENT_ID=$(printf '%s' "$VALIDATE_JSON" | jq -r '.result.combineDetails.parentWorkitemId')
# one --child-work-item-id arg per child, safe for use as a flag array
CHILD_ARGS=()
while IFS= read -r cid; do CHILD_ARGS+=(--child-work-item-id "$cid"); done < <(
printf '%s' "$VALIDATE_JSON" | jq -r '.result.combineDetails.childWorkitemsId[]')
fi
Then combine using those derived values (skip this command entirely when
is not
):
bash
sf devops work-item combine \
--parent-work-item-id "$PARENT_ID" \
"${CHILD_ARGS[@]}" \
--target-stage-id <stage-id> \
--target-org <alias> \
--json
- expands to one
--child-work-item-id <id>
pair per child work item
- The parent work item is the primary item that continues through the pipeline; child changes merge into the parent's branch during promotion
- After combining, promote the parent work item ID in step 5
-
Complete the promotion to finalize — advances the work items in the target stage:
bash
sf devops promotion complete --target-stage-id <target-stage-id> --target-org <alias> --json
- Run after the promote deploy succeeds to mark the promotion done in the target stage
- is required (same target stage the work items were promoted to)
-
Report the outcome:
- Confirm the CLI returned status 0 for each step
- Report the promotion/deploy identifier and note that async deploy completion is tracked separately
- Do NOT block or busy-wait inside this skill — surface the identifier and return
- State the promotion clearly: e.g., "Work item promotion initiated (source stage → target stage). Deploy ID: <id>. Poll this ID to confirm deploy completion, then run promotion complete."
Outputs are derived from
,
, and
sf devops promotion complete
CLI commands. Async deploy completion is NOT produced by the promote call — poll the returned identifier separately before completing.