Skip to main content

Use Vibgrate CLI Output Programmatically

Drive automation from Vibgrate's JSON output and exit codes. Read the DriftScore from JSON, gate with --drift-budget and --fail-on, and branch on the exit status.

Difficulty
Advanced
Duration
20 minutes
Steps
5

The Vibgrate CLI is built to be scripted. Between stable JSON output and meaningful exit codes, you can make automation decisions from drift results: fail a build, open a ticket, skip a deploy, or notify a channel. This tutorial drives a script from vg output.

Prerequisites

  • The Vibgrate CLI installed (npm i -g @vibgrate/cli)
  • Basic shell scripting

Steps

1. Emit JSON for parsing

vg scan --format json --out drift.json

JSON is the contract your script reads.

2. Read the DriftScore in a script

Load drift.json in your language of choice and read the DriftScore field to make decisions. Keep the parsing tolerant so format additions do not break you.

3. Gate on a drift budget

Let the CLI enforce a threshold for you and signal via exit code.

vg scan --drift-budget 60

If drift exceeds the budget, the scan exits non-zero.

4. Branch on the exit code

Use --fail-on to control which severities fail the run, then branch on the exit status in your script.

vg scan --fail-on error

A zero exit means the gate passed; a non-zero exit means it failed.

5. Trigger downstream steps

In your script, run the gate, then act on the result: continue the pipeline on success, or open a ticket and notify the team on failure. The JSON file gives you the details to include.

Verification

Force a low budget to confirm a non-zero exit, then a generous budget to confirm a zero exit. Your script's branches should fire accordingly. Consult the documented exit codes to map statuses precisely.

Next Steps

  • Visualize the same JSON: "Export JSON for Custom Dashboards".
  • Feed findings into security tools: "Produce a SARIF Report for Security Tooling".

Prerequisites

  • Vibgrate CLI installed
  • Basic shell scripting
  • A project to scan

Steps

  • 1
    Emit JSON for parsing
  • 2
    Read the DriftScore in a script
  • 3
    Gate on a drift budget
  • 4
    Branch on the exit code
  • 5
    Trigger downstream steps

Category

Vibgrate