mcpField
C
configuring-quality-gate

configuring-quality-gate

github.com/forcedotcomTesting & quality1.1k266 installsUpdated 1d ago
Repository

About configuring-quality-gate

A skill for creating a quality gate, adding requested rules, and linking it to a DevOps Center test suite stage. It requires an impact preview and explicit confirmation before making changes.

Key features

  1. 01Supports pass-percentage, severity, and essential rules
  2. 02Creates a quality gate and requested rules
  3. 03Links the gate to a test suite stage
  4. 04Requires impact preview and confirmation

Use cases

  1. 01Enforce minimum test pass percentage
  2. 02Limit allowed failure severity
  3. 03Require all essential tests to pass

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/forcedotcom/sf-skills --skill configuring-quality-gate

After installing, type/configuring-quality-gatein Claude Code to confirm it loaded.

Details

From the project README

Prerequisites

Load checking-devops-prerequisites first — Prerequisites 1–4 AND Prerequisite 5 (stage). You need doce-org-alias, pipelineId, stageId, and the target DevopsTestSuiteStage record Id.

Inputs required

InputSource
nameUser-provided name for the quality gate
rulesList of {type, threshold?} — see rule types below
doce-org-aliasEstablished in Prereq 1
testSuiteStageIdTarget DevopsTestSuiteStage record Id (Prereq 5)

Rule types

TypeDescriptionThreshold
PASS_PERCENTAGEMinimum % of tests that must passRequired (0–100)
SEVERITYMaximum allowed severity level of failuresRequired (numeric, e.g. 1–5)
ESSENTIALAll essential tests must passNot required

MANDATORY IMPACT PREVIEW

Before executing any commands, show the user this preview and wait for explicit confirmation:

"Here's what this quality gate will enforce on <stageName>:

  • Rule: <type> — <description>
  • Threshold: <value>
  • Affected pipelines: <list>

Confirm to apply?"

Never proceed past this point without showing the impact preview first and receiving explicit confirmation.


Confirmation gate

Only proceed with the steps below after the user has explicitly confirmed (e.g., "yes", "confirm", "go ahead"). If the user declines or does not confirm, stop and do not execute any commands.


Step 1 — Create the gate record

sf api request rest \
  "/services/data/v67.0/connect/devopstesting/qualityGate" \
  --method POST \
  --body '{"name": "<gateName>"}' \
  --target-org <doce-org-alias>

Extract qualityGateId from the response.

Step 2 — Create each rule as a sObject record

Rules are not accepted in the Connect API payload — create them as DevopsQualityGateRule records directly. Only create rules the user has requested. ESSENTIAL has no threshold.

sf data create record \
  --sobject DevopsQualityGateRule \
  --values "DevopsQualityGateId='<qualityGateId>' Rule='PASS_PERCENTAGE' Threshold=<value>" \
  --target-org <doce-org-alias> --json

sf data create record \
  --sobject DevopsQualityGateRule \
  --values "DevopsQualityGateId='<qualityGateId>' Rule='ESSENTIAL'" \
  --target-org <doce-org-alias> --json

sf data create record \
  --sobject DevopsQualityGateRule \
  --values "DevopsQualityGateId='<qualityGateId>' Rule='SEVERITY' Threshold=<value>" \
  --target-org <doce-org-alias> --json

Step 3 — Link the gate to the suite stage

Update the DevopsTestSuiteStage record to link the new gate:

sf data update record \
  --sobject DevopsTestSuiteStage \
  --record-id <testSuiteStageId> \
  --values "IsQualityGateEnabled=true DevopsQualityGateId='<qualityGateId>'" \
  --target-org <doce-org-alias> --json

On success

Confirm to the user:

"Quality gate <gateName> created with <N> rule(s) and assigned to <suiteName> on <stageName>."

Error handling

Never expose raw API errors. Use the following responses:

StatusResponse
400"The quality gate configuration is invalid. Check that all rule types and thresholds are correct."
403"You don't have permission to configure quality gates on this org."
500"A server error occurred. Try again in a few minutes."

Related skills

  • To re-run a gate after meeting threshold, use running-devops-test-suite (retrigger mode).
  • To assign or map suites to stages, use managing-suite-assignments.

Comments

Markdown supported