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 Issues Count
High Severity Issues
New Coverage Percentage
Duplicated Lines Density
Infrastructure as Code (IaC)
Software Composition Analysis (SCA)
Sample Configuration
Comprehensive Quality Configuration
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
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
- Security First: Prioritize security metrics 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