CLI automation and exit behavior
Build shell and CI jobs that parse JSON, preserve errors, and verify remote state before retrying.
Build shell and CI jobs that parse JSON, preserve errors, and verify remote state before retrying.
Outcome: Build shell and CI jobs that parse JSON, preserve errors, and verify remote state before retrying.
unitlab project list --json > projects.json
unitlab batch-queue status PROJECT_ID BATCH_QUEUE_ID --json > status.jsonState-changing commands return a non-zero exit status on validation or API failure. Project upload also exits non-zero when any file failed, even if other files succeeded. Capture standard error for diagnosis and standard output for JSON parsing.
Do not parse decorative human output. Do not retry a create, attach, move, or release command blindly after a timeout; first list or retrieve the target resource to determine whether the server accepted the operation.
Execution surface
Pinned unitlab==3.0.0 command in the intended Python 3.10+ environment.
Machine contract
Use --json; human-readable output is not an automation interface.
Target resolution
Resolve stable IDs with a read command before a state-changing command.
Success evidence
Exit status, JSON result, returned IDs, and a read-after-write state check.
Authentication or authorization fails
Stop, correct the service identity or access model, rotate exposed credentials, and rerun a read-only check.
Validation or entitlement rejects the operation
Correct the input or entitlement; do not retry an unchanged request.
A request times out
Inspect remote state before repeating a mutation because the server may have accepted it.
Asynchronous processing exceeds its deadline
Preserve the Batch Queue or release ID, continue bounded monitoring, and inspect item-level failures.
Only part of a batch succeeds
Keep successful identifiers, isolate failed rows, and retry only the corrected subset.
Pin and test the production SDK version. Use stable IDs, keep secrets out of logs and command history, and record the correlation ID, target IDs, counts, final state, and redacted error details for material state changes.
Related Unitlab capability guides: AI training-data annotation