Environment Variables
1 min read
Environment variables take precedence over the credentials file. They are the recommended way to authenticate in CI/CD pipelines and automated environments.
Supported Variables
| Variable | Description | Default |
|---|---|---|
OPENCX_API_KEY | API token for authentication. When set, the credentials file is ignored. | -- |
OPENCX_API_URL | Base URL of the OpenCX API. Only used when OPENCX_API_KEY is also set. | "https://api.open.cx" |
When to Use Environment Variables
- CI/CD pipelines -- set
OPENCX_API_KEYas a secret in your CI provider. - Docker containers -- pass the key at runtime instead of baking credentials into the image.
- Multiple environments -- switch between staging and production by changing
OPENCX_API_URL.
CI/CD Example
yaml
# GitHub Actions
steps:
- name: Push content
run: opencx content push
env:
OPENCX_API_KEY: ${{ secrets.OPENCX_API_KEY }}
yaml
# GitLab CI
push_content:
script:
- opencx content push
variables:
OPENCX_API_KEY: $OPENCX_API_KEY
Notes
OPENCX_API_URLhas no effect unlessOPENCX_API_KEYis also set. The URL fromopencx.jsonis used independently for project-level configuration.- If neither environment variables nor a credentials file are found, the CLI exits with an error prompting you to run
opencx auth login.