Skip to content

CI pipeline fails: secret not available

Quick summary

Your CI pipeline fails — a secret or environment variable referenced in the pipeline is not set.

Why this happens

  • The secret was not added to the CI system's secret store

  • The secret name in the pipeline does not match the name in the CI configuration

  • The secret is scoped to a different environment or branch and is not available in the current run

Minimal example

✗ Broken code
# .github/workflows/deploy.yml
steps:
  - name: Deploy
    run: npm run deploy
    env:
      API_KEY: ${{ secrets.API_KEY }} # secret not configured in GitHub
✓ Fixed code
# Add the secret in GitHub: Settings > Secrets and variables > Actions > New secret
# Name: API_KEY, Value: your-api-key
steps:
  - name: Deploy
    run: npm run deploy
    env:
      API_KEY: ${{ secrets.API_KEY }} # now available

Adding the API_KEY secret to the GitHub repository's secret store makes it available to the pipeline step.

How to diagnose

  • Check the CI pipeline error message for the missing secret or environment variable name

  • Verify the secret exists in the CI system's secret store with the correct name

  • Check the secret scope and availability for the current branch or environment

How to fix

  • Add the missing secret to the CI system's secret store

  • Correct the secret name in the pipeline to match the CI configuration

  • Make the secret available in the current environment or branch scope

How to prevent

  • Document all required secrets and validate them at the start of the pipeline

  • Use a secrets management tool and consistent naming conventions across environments

Related Resources

Related Glossary

Related Lessons

  • CI/CD

    Learn about secrets.

← Back to language