Interview Prep/Jenkins/Integrations & delivery

Your SonarQube analysis must decorate PRs with comments and fail PR builds on new issues only. How do you configure the pipeline?

AdvancedScenarioIntegrations & delivery
Answer

Situation read → PR analysis needs PR parameters and an edition that supports it.

What I'd do →

  1. Use SonarQube Developer Edition or above (or SonarQube Cloud); Community Build lacks branch/PR analysis natively.
  2. Pass PR parameters on PR builds:
    sonar-scanner -Dsonar.pullrequest.key=$CHANGE_ID \
      -Dsonar.pullrequest.branch=$CHANGE_BRANCH -Dsonar.pullrequest.base=$CHANGE_TARGET
    
  3. Configure the GitHub integration in SonarQube for decoration.
  4. Quality gate on "new code" conditions; waitForQualityGate abortPipeline: true.

Why → New-code gates stop regressions without forcing teams to fix legacy debt first.

Interview tip → Many Sonar plugins auto-detect PR params in Jenkins multibranch; still know the properties.

All Jenkins questions Roadmap: Jenkins

More on Integrations & delivery