CLI in CI/CD pipelines
The CLI is designed for automation: structured JSON output, predictable exit codes, environment-variable authentication, and no interactive prompts.
Setup in CI
Install the CLI in a setup step:
Authenticate via environment variables:
Set UPLOADCARE_PUBLIC_KEY and UPLOADCARE_SECRET_KEY in your CI platform’s
secret management system.
Never hardcode API keys in pipeline configuration files. Use your platform’s secrets or environment variable management instead.
Exit codes
The CLI uses predictable exit codes so scripts can branch on success or failure:
Use in shell conditionals:
Batch operations return exit code 1 for partial failures. The JSON output includes
a problems field with per-file error details:
GitHub Actions example
Batch operations
Upload all files in a directory:
Upload file paths from stdin:
Delete all unstored files:
Store all temporary files:
Preview destructive operations with dry-run:
Webhook management during deployment
Register or update webhooks as part of your deployment process:
Create a webhook:
Update a webhook URL on deploy:
List current webhooks:
Multi-environment management
Use named projects or the --project flag to target different environments:
In CI, switch environments via the UPLOADCARE_PROJECT variable:
See Configuration for setting up named projects.