Installation
Before using CodeAnt CI Scan 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
codeant-ci-scan task will be available in all pipelines across your organization.
Azure Pipelines Workflow
Add the following to yourazure-pipelines.yml. It will trigger on every push to your target branch and kick off a CodeAnt analysis scan:
With Optional Parameters
You can customize the scan behavior with additional parameters:Important:
- In Project → Pipelines → Library, add a secret variable named
ACCESS_TOKENwith your personal access token or repo token.
How it works
- Setup environment The task automatically extracts organization, project, and repository information from Azure DevOps built-in variables.
-
Download script
The task fetches the CI scan script (
start_scan.sh) from the CodeAnt API endpoint. -
Trigger scan
The script initiates a CI scan for your commit, optionally waiting for results based on the
noWaitparameter. -
Pipeline feedback
- Success: Scan completes successfully (or is triggered in no-wait mode)
- Failure: Scan fails or detects critical issues, blocking the build
Script Parameters
Thestart_scan.sh script accepts the following parameters:
Required Parameters
| Parameter | Flag | Description | Example |
|---|---|---|---|
| Access Token | -a, --access-token | Authentication token for CodeAnt API. Can be a Personal Access Token (PAT) or repository token | $(ACCESS_TOKEN) |
| Repository | -r, --repo | Repository name in organization/project/repository format | myorg/myproject/myrepo |
| Commit ID | -c, --commit-id | Git commit SHA to analyze | $(Build.SourceVersion) |
| Service | -s, --service | Git service provider | azuredevops, github, gitlab |
Optional Parameters
| Parameter | Flag | Default | Description | |
|---|---|---|---|---|
| Branch | -b, --branch | (empty) | Branch name for the analysis | main, develop |
| Include Files | -i, --include-files | (empty) | Glob patterns for files to include in analysis | "src/**/*.js" |
| Exclude Files | -e, --exclude-files | (empty) | Glob patterns for files to exclude from analysis | "**/test/**" |
| Polling Interval | -p, --polling-interval | 30 | Seconds between result polling attempts | 20 |
| Timeout | -t, --timeout | 300 | Maximum seconds to wait for results | 600 |
| No Wait | -n, --no-wait | false | Skip waiting for results, only trigger the scan | (flag only) |
Execution Time Considerations
⏱️ Performance Options:-
With result waiting (default): ~7 minutes
- Triggers scan and waits for complete analysis results
- Includes both security and SCA (Software Composition Analysis) results
- Best for comprehensive CI/CD pipelines where you need immediate feedback
-
With
--no-waitflag: ~2 minutes- Only triggers the scan and returns immediately
- Results can be fetched later or viewed in the CodeAnt dashboard
- Ideal for faster CI runs or when results can be processed asynchronously
Example Configurations
Fast CI Mode (No Wait)
For quick pipeline runs where you don’t need immediate results:Comprehensive Analysis (Wait for Results)
For thorough analysis with complete results:Custom File Filtering
To scan only specific files or exclude certain paths:Branch-Specific Configuration
Run different scan modes based on the branch:Best Practices
- Use fast mode for PRs: Set
noWait: 'true'for pull request pipelines to keep them fast - Full analysis for main: Use complete analysis (wait for results) on main/master branch merges
- Adjust timeouts: Increase timeout for larger repositories that take longer to analyze
- File filtering: Use include/exclude patterns to focus analysis on relevant code
- Keep tokens secure: Always use Azure DevOps Variable Groups or Pipeline Variables for tokens
- Monitor performance: Track scan times and optimize based on your repository size
Troubleshooting
Task not found
If you see “Task ‘codeant-ci-scan’ 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
Scan times out
If the scan takes longer than expected:- Increase the timeout using
timeout: '600'(10 minutes) or higher - Check if the CodeAnt service is operational
- Consider using
noWait: 'true'for faster pipeline execution - 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 CI scanning is 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
Windows compatibility issues
If running on Windows agents:- Ensure Git Bash or WSL is available on the agent
- The task automatically detects Windows and uses bash for script execution
- Consider using Linux agents (
ubuntu-latest) for best compatibility
Advanced Configuration
Custom API Endpoint
If you’re using a self-hosted CodeAnt instance:Parallel Jobs
Run scans in parallel for different directories:With CodeAnt CI Scan in place, every push will automatically trigger a comprehensive code analysis, helping you maintain high code quality and security standards in your Azure DevOps repositories.