datadog-ci "Missing DATADOG_API_KEY" in CI
datadog-ci reads the API key from the environment, and when DATADOG_API_KEY (or DD_API_KEY) is empty it stops immediately with "Missing DATADOG_API_KEY in your environment." No request reaches Datadog.
What this error means
A datadog-ci subcommand (sourcemaps, junit, synthetics) exits non-zero with "Missing DATADOG_API_KEY in your environment." before uploading anything.
[ERROR] Missing DATADOG_API_KEY in your environment.Common causes
The API key secret is not exposed to the step
The workflow never set DATADOG_API_KEY, or used a different name, so datadog-ci finds nothing to authenticate with.
The run is on a fork without secrets
Pull requests from forks do not receive repository secrets, so the key resolves to empty in that context.
How to fix it
Export DATADOG_API_KEY from a secret
- Store the Datadog API key as a CI secret.
- Expose it as
DATADOG_API_KEYin the step env. - Re-run the datadog-ci command.
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
run: datadog-ci junit upload --service web ./reportsGuard against an empty key
Fail fast with a clear message if the variable is missing, instead of a deep error later.
test -n "$DATADOG_API_KEY" || { echo "DATADOG_API_KEY is empty"; exit 1; }How to prevent it
- Set the API key from a secret at the job level.
- Use the exact env name datadog-ci expects (
DATADOG_API_KEY). - Skip Datadog uploads on fork-triggered runs where secrets are absent.