How to Block Merges to Main Branch Based on SonarQube Analysis in Feature Branches

I’m currently using SonarQube Community Edition and have a question about enforcing code quality checks in feature branches before allowing merges to the main branch. Here’s my situation:

  1. GitLab CI/CD Pipeline:
  • We have a .gitlab-ci.yml file that includes different configurations for different branches:
    • .gitlab-ci-dev.yml for the main branch.
    • .gitlab-ci-prod.yml for the prod branch.
    • .gitlab-ci-br.yml for feature branches.
  • Developers create feature branches from main, push changes, and then merge those changes back into main.
    when developer create merge request the .gitlab-ci-br.yml get triggered if the sonar analysis fail the merge request blocked

I want to block merges to the main branch if there are issues in the SonarQube analysis for the feature branch. Essentially, I want to ensure that code quality standards are met before allowing any changes to be merged into main . is it possible in community edition

Hey there.

You’re looking for pull request anlaysis, available in SonarQube’s Developer Edition and higher.