All guides

Cloptima CLI for CI/CD Cost Guardrails

Use the CLI in your pipelines with access tokens and JSON output to enforce cost policies before deploy.

9 min read Updated March 2026Developer
On this page
  1. 01Why Add Cost Checks to CI/CD
  2. 02Create a Pipeline Token
  3. 03Use Deterministic Command Inputs
  4. 04Typical Pipeline Checks
  5. 05Example Workflow Pattern
  6. 06Operational Best Practices

01

Why Add Cost Checks to CI/CD

Cost regressions are cheapest to catch before deployment. CLI checks let teams validate spend impact alongside unit tests, security scans, and performance gates in a single release workflow.

02

Create a Pipeline Token

Create a Personal Access Token from your Cloptima settings for the target organization and store it as CLOPTIMA_ACCESS_TOKEN in your CI secret manager. Rotate tokens periodically and scope access to least privilege.

03

Use Deterministic Command Inputs

Pass UUIDs for cloud-account-id and cluster-id in CI to avoid name ambiguity. In scripts, always set --output json and parse structured fields rather than relying on human-readable table output.

04

Typical Pipeline Checks

Common checks include: failing when active anomalies exceed a threshold, blocking deploys when projected costs exceed policy limits, and exporting recommendations as build artifacts for follow-up.

05

Example Workflow Pattern

Step 1: run cloptima costs with a fixed date window. Step 2: run cloptima anomalies and parse JSON severity counts. Step 3: run cloptima recommend and attach output to PR/build logs. Step 4: fail pipeline when policy conditions are met.

06

Operational Best Practices

Use separate tokens per environment, keep immutable build logs for auditability, and alert owners with structured outputs (Slack/Jira/GitHub checks). Treat cost guardrails like security gates: measurable, automated, and reviewed regularly.

Put This Guide Into Practice

Cloptima automates the strategies described in this guide.

No credit card required
5-minute setup
Free trial