How do you prevent secrets from leaking into build logs?
IntermediateProductionSecrets and Credentials
Answer
Use the platform's masking (GitHub ::add-mask::, GitLab masked variables, Jenkins credentials binding), never set -x around secret use, avoid passing secrets on command lines (visible in process lists; use stdin or env vars), disable verbose/debug flags in production pipelines, don't cat config files that contain tokens, and scan logs and artifacts for secrets. Masking works by exact match, so transformed values (base64, URL-encoded, split) are not masked.
echo "$REGISTRY_TOKEN" | docker login ghcr.io -u "$USER" --password-stdin
More on Secrets and Credentials
Why are long-lived credentials in CI a problem, and what is the modern alternative?BeginnerHow do you manage application secrets from build to runtime?IntermediateHow do you store secrets in Git safely for GitOps?IntermediateHow do you detect secrets committed to a repo?BeginnerWhat do you do after a secret is committed to Git?IntermediateHow do you use HashiCorp Vault with CI/CD?Advanced