Installation
Before using CodeAnt Quality Gates in your Azure Pipelines, you need to install the CodeAnt extension from the Azure DevOps Marketplace:- Go to the Azure DevOps Marketplace and search for “CodeAnt AI” or directly download from here
- Click Get it free
- Select your Azure DevOps organization
- Click Install
CodeAntQualityGate@1 task will be available in all pipelines across your organization.
Repository Scenarios
CodeAnt Quality Gate supports multiple repository configurations in Azure DevOps:| Scenario | Repository Location | Pipeline Location | Configuration |
|---|---|---|---|
| Scenario 1 | Azure Repos | Azure DevOps | Auto-detected (default) |
| Scenario 2 | GitHub | Azure DevOps | Requires service and repo inputs. commitId auto-detected from BUILD_SOURCEVERSION if available. |
| Scenario 3 | GitLab | Azure DevOps | Requires service and repo inputs. commitId auto-detected from BUILD_SOURCEVERSION if available. |
| Scenario 4 | Bitbucket | Azure DevOps | Requires service and repo inputs. commitId auto-detected from BUILD_SOURCEVERSION if available. |
Scenario 1: Azure Repos + Azure DevOps Pipeline
When your repository is hosted in Azure Repos:Note: No additional configuration needed. The task automatically extracts information from these Azure DevOps built-in variables:
SYSTEM_TEAMPROJECT- Project nameBUILD_REPOSITORY_NAME- Repository nameBUILD_SOURCEVERSION- Commit SHA
Scenario 2: GitHub Repository + Azure DevOps Pipeline
Parameters for GitHub
| Parameter | Value | Description |
|---|---|---|
service | github | Specifies GitHub as the repository provider |
repo | owner/repo | Repository in owner/repository-name format |
commitId | $(Build.SourceVersion) | Commit SHA to analyze. Auto-detected from BUILD_SOURCEVERSION if available, otherwise required. |
Scenario 3: GitLab Repository + Azure DevOps Pipeline
Parameters for GitLab
| Parameter | Value | Description |
|---|---|---|
service | gitlab | Specifies GitLab as the repository provider |
repo | group/project | Repository in group/project-name or user/project-name format |
commitId | $(Build.SourceVersion) | Commit SHA to analyze. Auto-detected from BUILD_SOURCEVERSION if available, otherwise required. |
Scenario 4: Bitbucket Repository + Azure DevOps Pipeline
Parameters for Bitbucket
| Parameter | Value | Description |
|---|---|---|
service | bitbucket | Specifies Bitbucket as the repository provider |
repo | workspace/repo | Repository in workspace/repository-name format |
commitId | $(Build.SourceVersion) | Commit SHA to analyze. Auto-detected from BUILD_SOURCEVERSION if available, otherwise required. |
Video Tutorial
Watch this video to learn how to integrate CodeAnt AI into your CI/CD pipelines:Azure Pipelines Workflow
Add the following to yourazure-pipelines.yml. It will trigger on every push to your repository and run quality gate checks to detect secrets and other security issues:
With Optional Parameters
You can customize the timeout and polling interval:Important:
- In Project → Pipelines → Library, add a secret variable named
ACCESS_TOKENwith your personal access token or repo token.
How it works
-
Setup environment
Extract organization, project, and repository information from Azure DevOps built-in variables. -
Download script
We fetch the quality gates script (quality_gates.sh) from the CodeAnt API endpoint. -
Start scan
The script initiates a quality gate scan for your commit using the-o startoperation. -
Poll for results
The script polls for scan results using the-o resultsoperation with:- Timeout: 300 seconds (5 minutes)
- Poll interval: 15 seconds
-
Pipeline feedback
- Success: Quality gate passes if no secrets are detected
- Failure: Quality gate fails if secrets are found, blocking the build
Quality Gate Checks
The quality gate performs comprehensive checks including:Security and Code Quality Checks
- Secret Detection: Scans for hardcoded secrets, API keys, passwords, and tokens
- SAST (Static Application Security Testing): Detects security vulnerabilities in source code
- SCA (Software Composition Analysis): Identifies vulnerabilities in third-party dependencies
- IaC (Infrastructure as Code): Scans infrastructure configuration files for security issues
- Duplicate Code Detection: Identifies code duplication to improve maintainability
- Analyzes only the changed lines since your merge base commit
- Uses high-confidence detection to minimize false positives
- Blocks the build if any issues are found
Best Practices
- Run on all branches: Quality gates should run on every push to catch issues early
- Block builds: Configure branch policies to require quality gate pipeline success before merging
- Review failures: When quality gates fail, review the detected issues immediately
- Keep tokens secure: Never commit access tokens directly - always use Azure DevOps Variable Groups or Pipeline Variables
- Use variable groups: Store your
ACCESS_TOKENin a Variable Group for reuse across pipelines - Set appropriate timeouts: Adjust timeout values based on your repository size and complexity
- Monitor performance: Track how long quality gate checks take and optimize if needed
Troubleshooting
Task not found
If you see “Task ‘codeant-quality-gate’ not found”:- Ensure the CodeAnt extension is installed in your Azure DevOps organization
- Go to Organization Settings → Extensions to verify installation
- Check that the extension is enabled for your project
Quality gate times out
If the scan takes longer than expected:- Increase the timeout using
timeout: '600'(10 minutes) - Check if the CodeAnt service is operational
- Consider optimizing your repository size
- Review your network connectivity to the CodeAnt API
Authentication failures
If you see “Access token invalid” or “ACCESS_TOKEN is required”:- Verify your
ACCESS_TOKENvariable is correctly configured in Pipeline Variables or Variable Groups - Ensure the token has appropriate repository permissions
- Check that the variable is marked as secret
- Verify the token hasn’t expired
No results returned
If the scan completes but returns no results:- Check that quality gates are enabled for your repository in CodeAnt
- Verify the commit SHA is correct
- Ensure your Azure DevOps organization has proper integration with CodeAnt
- Check the CodeAnt dashboard to see if the scan was registered
Repository format issues
If you see “Invalid repository format” or “Required Azure DevOps variables not found”:- Verify that environment variables are being set correctly
- Check that
BUILD_REPOSITORY_NAME,BUILD_SOURCEVERSION, andSYSTEM_TEAMPROJECTare available - The task expects repository format:
organization/project/repository - Add debugging by checking the task logs for environment variable values
Pipeline fails silently
If the pipeline exits without clear error:- Add
set -eat the beginning of your script to fail on any error - Add error handling:
Extended Timeout for Large Repositories
For larger repositories that take longer to scan:On-Premise Deployment
If you are using a self-hosted CodeAnt instance, you can specify a custom API endpoint using theapiBase parameter:
Note: The apiBase parameter is only required for on-premise deployments. Cloud users do not need to configure this.
With quality gates in place, every push will automatically be scanned for security issues, helping you maintain code security and compliance standards in your Azure DevOps repositories.