Skip to main content

Overview

envcheck is designed to work seamlessly in CI/CD pipelines. Use the --json flag to get machine-readable output that can be parsed by your automation scripts.

GitHub Actions

Basic Workflow

Add envcheck to your GitHub Actions workflow to validate the environment before running tests or deployments:
.github/workflows/validate.yml

Advanced Workflow with Parsing

Parse the JSON output and fail the build only on errors, allowing warnings to pass:
.github/workflows/validate-advanced.yml

GitLab CI

Basic Pipeline

Integrate envcheck into your GitLab CI pipeline:
.gitlab-ci.yml

Multi-Environment Pipeline

Validate different environments with separate configurations:
.gitlab-ci.yml

Jenkins

Declarative Pipeline

Jenkinsfile

CircleCI

.circleci/config.yml

Best Practices

Use Config Files

Store your .envcheck.yaml in version control so all developers and CI/CD systems use the same validation rules.

Cache the Binary

Cache the envcheck binary in your CI/CD pipeline to speed up builds. Most CI systems support caching between runs.

Separate Configs per Environment

Use different configuration files for development, staging, and production environments:
  • .envcheck.dev.yaml - Minimal requirements for local development
  • .envcheck.staging.yaml - Staging environment requirements
  • .envcheck.prod.yaml - Strict production requirements

Parse JSON Output

Don’t rely solely on exit codes. Parse the JSON output to get detailed information about failures and create custom notifications.

Environment Variables in CI

When validating environment variables in CI/CD, remember to:
  1. Set secrets in your CI system: Use GitHub Secrets, GitLab CI Variables, or Jenkins Credentials
  2. Mark sensitive vars as optional: Use required: false for secrets in your config
  3. Use different configs: Separate validation rules for CI vs local development
.envcheck.ci.yaml
Use envcheck --config .envcheck.ci.yaml in your CI pipeline and .envcheck.yaml locally.

Exit Codes

envcheck uses standard exit codes for CI/CD integration:
  • 0 - All checks passed (may include warnings)
  • 1 - One or more checks failed with errors
Warnings do not cause a non-zero exit code. Use the JSON output if you need to fail on warnings.

Next Steps

JSON Output Format

Learn about the structure of JSON output

Troubleshooting

Common issues and solutions