Skip to content

[STORY-SCAN] SonarQube PR Scanning Integration (Multibranch Pipeline) #89

Description

@williammorrison2

SonarQube PR Scanning Integration (Multibranch Pipeline)

Objective

Enable SonarQube Pull Request and Branch scanning using the Jenkins Shared Library (sonarqube-lib) and multibranch pipeline setup.


Required Steps

1. Create GitHub Label (if not exists)

Create the following label in the repository:

  • Name: SonarQube
  • Description: SonarQube
  • Color: #D4C5F9

This label will be used for:

  • Auto-created issues from SonarQube failures
  • Manual tracking of SonarQube-related work

2. Setup GitHub Webhook

Configure webhook to trigger Jenkins:

Events:

  • Push
  • Pull Requests

Image

Image

Image


3. Add sonar-project.properties

# Format is $GHE_ORG_ID-$GHE_REPO_ID
sonar.projectKey=1459110-989134054

# Format is $GHE_ORG_NAME/$GHE_ORG_REPO
sonar.projectName=IBM/aiu-trace-analyzer

# Files / Folders to exclude. Note, this doesn't work unless entered in command-line
sonar.exclusions=""

# SonarQube Host URL
sonar.host.url=https://sonarqube-prod.apps.wdc-sonarqube-prod.core.cirrus.ibm.com

4. Add Jenkinsfile (Shared Library) Jenkinsfile.sonarqube

Note: This file will also be in the root directory of this repo (same location as the sonar-project.properties)

@Library('sonarqube-lib') _
multiBranchSonarQubeScan()

Expected Outcome

SonarQube scan runs on:

  • Pull Requests
  • Branch pushes

GitHub integration:

  • Commit status updates
  • PR comments (bugs, coverage, etc.)
  • Issue creation on Quality Gate failure (tagged with SonarQube label)

Notes

  • Quality Gate is non-blocking
  • Pipeline should not fail due to SonarQube issues
  • Ensure Jenkins Multibranch Pipeline is configured

Acceptance Criteria

  • SonarQube label exists in repository
  • Webhook configured and triggering Jenkins
  • sonar-project.properties added and validated
  • Jenkinsfile updated with shared library
  • PR scan successfully runs
  • Quality Gate result visible in PR
  • GitHub issue auto-created on failure (with SonarQube label)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions