Setup
1. Create Quality Gates Configuration File
Create aquality_gates_conditions.json file in the .codeant folder in your repository root:
2. Define Quality Gate Conditions
Thequality_gates_conditions.json file allows you to specify quality gate conditions that will be enforced for your repository, taking full precedence over organization or repository database configurations.
Configuration Format
Configuration Options
-
enabled(boolean, required): Controls whether quality gates are active for this repositorytrue: Enable quality gates with the defined conditionsfalse: Disable all quality gates for this repository
-
conditions(array, required when enabled): List of quality gate conditions to enforce -
metric(string): The code quality metric to monitor -
operator(string): Comparison operator for the condition"LESS_THAN": Value must be less than threshold"GREATER_THAN": Value must be greater than threshold"EQUALS": Value must equal threshold"LESS_THAN_OR_EQUALS": Value must be less than or equal to threshold"GREATER_THAN_OR_EQUALS": Value must be greater than or equal to threshold
-
value(string): The threshold value for comparison -
scope(array): Where the condition applies"commit": Apply to individual commits"pull_request": Apply to pull requests- Can specify both:
["commit", "pull_request"]
Available Metrics
Security Metrics
Secrets Detection:Code Quality Metrics
Critical Bugs:Software Composition Analysis (SCA)
Vulnerable Dependencies:Code Complexity Metrics
Cyclomatic Complexity:Sample quality_gates_conditions.json
Balanced Quality Configuration
Complete Configuration with File Exclusions
Disabled Quality Gates
Configuration Precedence
Quality gate settings follow a specific precedence hierarchy:-
Repository Configuration File (Highest Priority)
- If
.codeant/quality_gates_conditions.jsonexists in the repository, its settings take full precedence - A repository file with
"enabled": falsedisables quality gates for that repository - All conditions defined in the file override any organization or repository database settings
- If
-
Repository Database Settings (Medium Priority)
- Explicit repository-level settings in the database or S3
- Used when no repository configuration file exists
-
Organization Settings (Lowest Priority)
- Organization-level default settings
- Applied to repositories that have no repository-specific configuration
- Repo file exists with enabled: true → Uses conditions from repo file only
- Repo file exists with enabled: false → Quality gates disabled, ignores all other settings
- No repo file, repo DB has settings → Uses repo DB settings
- No repo file, no repo DB settings → Inherits from organization settings
- No repo file, repo explicitly disabled in DB → Quality gates disabled
How It Works
-
File Detection: CodeAnt AI automatically detects the
quality_gates_conditions.jsonfile in your.codeant/directory - Configuration Loading: When a commit or pull request is created, CodeAnt loads the quality gates configuration in precedence order
- Condition Evaluation: Each defined condition is evaluated against the code analysis results
-
Gate Status:
- Pass: All conditions meet their thresholds
- Fail: One or more conditions don’t meet their thresholds
- Integration: Results are reported to your Git provider as status checks on commits and pull requests
Best Practices
- Version Control: Store the configuration file in your repository so changes are tracked and reviewed
- Team Consensus: Discuss and agree on quality thresholds with your team before implementing
- Start Conservative: Begin with relaxed thresholds and gradually tighten as code quality improves
- Zero Tolerance for Secrets: Always set secrets detection to zero to prevent credential leaks
- Security First: Prioritize security metrics (secrets, vulnerabilities) over quality metrics
- Document Exceptions: If disabling quality gates, document the reason in your team’s documentation
- Regular Review: Periodically review and adjust thresholds as your codebase and team standards evolve
- Test Changes: Test configuration changes in a feature branch before applying to main branches
Migration from UI Configuration
If you’re currently using UI-based quality gate configuration and want to migrate to repository-based configuration:- Export Current Settings: Document your current quality gate conditions from the Analysis Configuration page
-
Create Configuration File: Add
.codeant/quality_gates_conditions.jsonwith equivalent settings - Test in Branch: Create a test pull request to verify the conditions work as expected
- Commit and Deploy: Once verified, merge the configuration file to your main branch
- Clean Up (Optional): You can keep or remove the UI-based configuration; the repository file will take precedence regardless