Interview › Security & DevSecOps
How do you integrate SonarQube into a Jenkins or GitHub pipeline? [Basic]
Answer
I integrate SonarQube by adding a scanner step to CI, passing project metadata and coverage reports, then waiting for the quality gate result. In Jenkins this commonly uses withSonarQubeEnv and waitForQualityGate; in GitHub Actions it uses a scanner action or Maven/Gradle task plus branch protection.
Technical explanation
The scanner should run after compilation/tests when coverage and test reports are available.
Authentication should use a scoped token stored in the CI secret manager, not hardcoded credentials.
The pull request should be protected so failing analysis prevents merge.
Hands-on example
GitHub Actions sketch:
- uses: actions/checkout@v4
- run: mvn -B verify sonar:sonar -Dsonar.projectKey=checkout
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}Then require the SonarQube quality-gate status check before merging to main.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Security & DevSecOps interview questions
- How does SonarQube measure code coverage, and does it run your tests? [Basic]
- What is a SonarQube hotspot, and how is it different from a vulnerability? [Basic]
- What is technical debt in SonarQube, and how is it estimated? [Basic]
- How do you handle false positives in SonarQube? [Basic]
- What metrics does SonarQube track (coverage, duplication, code smells, bugs, vulnerabilities)? [Basic]
- What is the difference between SonarQube and SonarCloud? [Basic]
- What does 'clean as you code' mean in SonarQube, and why focus on new code? [Basic]
- What is the difference between a quality gate and a quality profile in SonarQube? [Basic]