Print CI Environment Variable Names Without Secrets
Print the environment in a CI job with env | cut -d= -f1 | sort to show names only. Filtering by a name like TOKEN misses a URL that holds a password.
A build behaves differently on the runner, and you want to see its environment without writing credentials into a log everyone can read.
export API_TOKEN=abc123 DB_URL=postgres://app:[email protected]/app BUILD_ID=42
env | grep -E 'API_TOKEN|DB_URL|BUILD_ID' | grep -viE 'token|secret|password|key'
echo ---
env | grep -E 'API_TOKEN|DB_URL|BUILD_ID' | cut -d= -f1 | sortDB_URL=postgres://app:[email protected]/app
BUILD_ID=42
---
API_TOKEN
BUILD_ID
DB_URLFiltering by variable name hides API_TOKEN but passes DB_URL, which carries a password in the value, so the first listing leaks it. Printing only the names, up to the first equals sign, shows which variables exist and avoids the problem for every value, as the second listing shows. CI services mask secrets they know about, but only when the exact string appears, as the GitHub Actions documentation warns, and an encoded or sliced copy is not matched.
Print a single named value when you need it, with a short mask such as the first four characters. Variables that hold multi-line values have continuation lines that cut leaves in place, so use printenv -0 or env -0 when you must be exact. The grep in this example only limits the sample output and is not part of the idiom.