Piping & Scripting
Every command prints structured JSON to stdout and progress/warnings to stderr. This makes pega safe to use in pipelines:
pega cases get CASE-1 | jq '.id'
pega assignments perform ASSIGN-1 --action Submit --data @form.json > result.jsonInteractive mode in pipelines
Even in interactive mode, the final PATCH response is the only thing written to stdout — all prompts, summaries, and progress messages go to stderr. So this works:
pega assignments perform ASSIGN-1 --interactive | jqSuppressing progress output
Use --quiet to suppress stderr progress messages. Inquirer prompts in interactive mode are not suppressed by --quiet — they're user input, not progress chatter.
pega cases get CASE-1 --quiet | jq '.status'Exit codes
Scripts can rely on the following exit codes for error handling:
| Code | Meaning |
|---|---|
| 0 | success (including clean cancellation in interactive mode) |
| 1 | API/network error (HTTP 4xx/5xx, timeout, network failure) |
| 2 | invalid configuration or arguments |
| 130 | interrupted (Ctrl+C in interactive mode) |
Example: batch processing
#!/usr/bin/env bash
set -euo pipefail
# Fetch multiple cases and extract their statuses
for case_id in MYAPP-1 MYAPP-2 MYAPP-3; do
status=$(pega cases get "$case_id" --quiet | jq -r '.status')
echo "$case_id: $status"
doneThe script exits immediately on a non-zero exit code (exit code 1 or 2) thanks to set -e.
CI/CD usage
In continuous integration environments, bypass the token cache entirely to ensure each invocation performs a fresh OAuth exchange:
export PEGA_NO_CACHE=true
export PEGA_BASE_URL=https://your-instance.pega.com
export PEGA_CLIENT_ID=${{ secrets.PEGA_CLIENT_ID }}
export PEGA_CLIENT_SECRET=${{ secrets.PEGA_CLIENT_SECRET }}
pega auth login
pega cases get MYAPP-CASE-1 | jq '.status'With PEGA_NO_CACHE=true, the CLI never reads or writes ~/.pega-cli/token.json. Every invocation performs a fresh OAuth exchange, preventing stale token issues in CI environments.
The typical pattern is:
- Set
PEGA_NO_CACHE=trueto disable caching - Export the three required credentials from secrets or environment
- Run
pega auth loginto authenticate - Chain your commands with
&&to fail fast on errors