For the latest updates and improvements in production, open docs.codacy.com instead.
Integrating Codacy with your Git workflow#
This page is part of the following guided path:
Once you've configured your repository to best match your use case, integrate Codacy with your Git workflow to display analysis results and code coverage as status checks on your pull requests.
In particular, you can configure quality gates to block merging pull requests that don't meet the quality standards of your team. This ensures the quality of the changes to your codebase, preventing the introduction of security issues and untested code.
To integrate Codacy with your Git workflow, follow these steps:
- Configuring the quality gate rules
- Configuring the Git provider integration
- Blocking merging pull requests (optional)
1. Configuring the quality gate rules#
Review and adjust the quality gates of your repository to decide which pull requests should fail the Codacy quality gate.
Tip
The default quality gate rules are designed to help maintain the current code quality of your repository. In particular, the default value for the coverage rule might be demanding. Depending on factors such as the current code quality of your repository and the maturity of your team practices, consider the balance between implementing stricter quality gates and the possibility of delaying or blocking the development progress.
Codacy generally recommends that on a first stage you configure rules that focus on stopping new critical issues from entering your code base, such as:
- High severity issues
- Security issues
- Considerable drops in code coverage
Important
If you want to use code coverage to block merging pull requests that don't meet your standards, make sure that you enable the rule Diff coverage is under or Coverage variation is under. This is required for Codacy to report the coverage status directly on your pull requests.
2. Configuring the Git provider integration#
Make sure you enable the option Status checks (GitHub) or Pull request status (GitLab and Bitbucket).
Tip
Configure the default Git provider integration settings that Codacy applies to new repositories to help ensure that all new repositories have the same settings.
3. Blocking merging pull requests (optional)#
Once you've tested out Codacy for a while and you're happy with the level of feedback provided, you can decide to enforce the quality gates and use Codacy to block merging pull requests on your Git provider. This is the best way to protect your code from unwelcome changes and fully integrates code quality and coverage analysis into your development pipeline.
Important
To eliminate any false positives that could inadvertently block the work of your team, it's important that before activating this feature you:
- Validate that Codacy is reporting the intended status on your pull requests
- Double check you repository's tool and code pattern settings and quality gate settings
Follow the instructions from your Git provider to block merging pull requests if they don't pass the Codacy status check:
- GitHub: set Codacy as a required status check
- GitLab: only allow merge requests to be merged if the pipeline succeeds
- Bitbucket: configure Bitbucket to prevent a merge with unresolved merge checks
You're all set! 🎉#
Congratulations! You've successfully integrated and set up your first repository.
Share your feedback 📢
Did this page help you?
Thanks for the feedback! Is there anything else you'd like to tell us about this page?
255 characters left
We're sorry to hear that. Please let us know what we can improve:
255 characters left
Alternatively, you can create a more detailed issue on our GitHub repository.
Thanks for helping improve the Codacy documentation.
Edit this page on GitHub if you notice something wrong or missing.
If you have a question or need help please contact support@codacy.com.