Sonarqube Cloud + Bitbucket Cloud + Jenkins (on-prem) not discovering branches

Hi friends! I’m just setting up Sonarqube for the first time, and while it’s working, it is not detecting branches or pull requests for me.

Any help or hints would be greatly appreciated!

  • Sonar Scanner plugin for Jenkins v 2.18.2
  • Bitbucket Branch Source plugin 937.3.1
  • Pull request is created in Bitbucket Cloud
  • Build is performed in Jenkins using Multibranch Pipeline
  • PR is identified in a tab within Jenkins, so it is being detected there
  • Sonarqube analysis proceeds and completes okay
  • Sonarqube analysis appears under the “main” branch in the web UI instead of a pull request
  • Pull request is not annotated in Bitbucket

I’ve followed setup instructions in Branch analysis | SonarQube Cloud | Sonar Documentation

And jenkins-specific instructions in Setting up Jenkins | SonarQube Cloud | Sonar Documentation

Here is the slightly redacted SQ log:

[INFO] --- sonar:5.7.0.6970:sonar (default-cli) @ xxxx ---
[WARNING] Using an unspecified version instead of an explicit plugin version may introduce breaking analysis changes at an unwanted time. It is highly recommended to use an explicit version, e.g. 'org.sonarsource.scanner.maven:sonar-maven-plugin:5.7.0.6970'.
[INFO] Java 21.0.5 Eclipse Adoptium (64-bit)
[INFO] Linux 3.10.0-1160.108.1.el7.x86_64 (amd64)
[INFO] Communicating with SonarQube Cloud
[INFO] JRE provisioning: os[linux], arch[x86_64]
[ERROR] [stderr] Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="/var/lib/jenkins/jobs/xxxx/branches/PR-349/workspace@tmp/withMaven5ebaa999/pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder="/var/lib/jenkins/jobs/xxxx/branches/PR-349/workspace@tmp/withMaven5ebaa999" 
[ERROR] [stderr] Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="/var/lib/jenkins/jobs/xxxx/branches/PR-349/workspace@tmp/withMaven5ebaa999/pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder="/var/lib/jenkins/jobs/xxxx/branches/PR-349/workspace@tmp/withMaven5ebaa999" 
[INFO] Starting SonarScanner Engine...
[INFO] Java 21.0.9 Eclipse Adoptium (64-bit)
[WARNING] Property 'env.SONARQUBE_SCANNER_PARAMS' is encrypted. The encryption of scanner properties is deprecated and will soon be removed.
[INFO] Load global settings
[INFO] Load global settings (done) | time=494ms
[INFO] Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
[INFO] Loading required plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=139ms
[INFO] Load/download plugins
[INFO] Load/download plugins (done) | time=50ms
[INFO] Loaded core extensions: architecture, a3s, sca
[INFO] Process project properties
[INFO] Project key: xxxxxx
[INFO] Base dir: /var/lib/jenkins/jobs/xxxx/branches/PR-349/workspace
[INFO] Working dir: /var/lib/jenkins/jobs/xxxx/branches/PR-349/workspace/target/sonar
[INFO] Load project settings for component key: 'xxxx'
[INFO] Load project settings for component key: 'xxxx' (done) | time=523ms
[INFO] Found an active CI vendor: 'Jenkins'
[INFO] Check ALM binding of project 'xxxx'
[INFO] Detected project binding: BOUND
[INFO] Check ALM binding of project 'pxxxx' (done) | time=241ms
[INFO] Load branch configuration
[INFO] Load branch configuration (done) | time=1ms
[INFO] Create analysis
[INFO] Create analysis (done) | time=317ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=509ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=610ms
[INFO] Organization key: xxxx
[INFO] Preprocessing files...
[INFO] 2 languages detected in 214 preprocessed files (done) | time=329ms
[INFO] 0 files ignored because of inclusion/exclusion patterns
[INFO] 0 files ignored because of scm ignore settings
[INFO] Loading plugins for detected languages
[INFO] Load/download plugins
[INFO] Load/download plugins (done) | time=107ms
[ERROR] [stderr] SLF4J(W): No SLF4J providers were found.
[ERROR] [stderr] SLF4J(W): Defaulting to no-operation (NOP) logger implementation
[ERROR] [stderr] SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=194ms
[INFO] Indexing files...
[INFO] Project configuration:
[INFO]   Excluded sources: **/build-wrapper-dump.json
[INFO] 214 files indexed (done) | time=17ms
[INFO] Quality profile for java: Sonar way
[INFO] Quality profile for xml: Sonar way
[INFO] ------------- Run sensors on module xxxx
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=131ms
[INFO] Sensor cache enabled
[INFO] Load sensor cache
[INFO] Load sensor cache (1 MB) | time=1324ms
[INFO] Configured Java source version (sonar.java.source): 8, preview features enabled (sonar.java.enablePreview): false
[INFO] Sensor JavaSensor [java]
[INFO] Configured Java source version (sonar.java.source): 8, preview features enabled (sonar.java.enablePreview): false
[INFO] Server-side caching is enabled. The Java analyzer will not try to leverage data from a previous analysis.
[INFO] Using ECJ batch to parse 168 Main java source files with batch size 155 KB.
[INFO] Starting batch processing.
[INFO] The Java analyzer cannot skip unchanged files in this context. A full analysis is performed for all files.
[INFO] No boundary descriptors defined
[INFO] 100% analyzed
[INFO] Batch processing: Done.
[INFO] Did not optimize analysis for any files, performed a full analysis for all 168 files.
[WARNING] Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
[WARNING] Use of preview features have been detected during analysis. Enable DEBUG mode to see them.
[INFO] Using ECJ batch to parse 44 Test java source files with batch size 155 KB.
[INFO] Starting batch processing.
[INFO] 100% analyzed
[INFO] Batch processing: Done.
[INFO] Did not optimize analysis for any files, performed a full analysis for all 44 files.
[WARNING] Use of preview features have been detected during analysis. Enable DEBUG mode to see them.
[INFO] No "Generated" source files to scan.
[INFO] Sensor JavaSensor [java] (done) | time=20830ms
[INFO] Sensor JaCoCo XML Report Importer [jacoco]
[INFO] 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
[INFO] No report imported, no coverage information will be imported by JaCoCo XML Report Importer
[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms
[INFO] Sensor IaC hadolint report Sensor [iac]
[INFO] Sensor IaC hadolint report Sensor [iac] (done) | time=0ms
[INFO] Sensor Java Config Sensor [iac]
[INFO] There are no files to be analyzed for the Java language
[INFO] Sensor Java Config Sensor [iac] (done) | time=6ms
[INFO] Sensor IaC Docker Sensor [iac]
[INFO] There are no files to be analyzed for the Docker language
[INFO] Sensor IaC Docker Sensor [iac] (done) | time=2ms
[INFO] Sensor IaC GitHub Actions Sensor [iac]
[INFO] There are no files to be analyzed for the GitHub Actions language
[INFO] Sensor IaC GitHub Actions Sensor [iac] (done) | time=0ms
[INFO] Sensor IaC actionlint report Sensor [iac]
[INFO] Sensor IaC actionlint report Sensor [iac] (done) | time=0ms
[INFO] Sensor IaC Shell Sensor [iac]
[INFO] There are no files to be analyzed for the Shell language
[INFO] Sensor IaC Shell Sensor [iac] (done) | time=0ms
[INFO] Sensor ThymeLeaf template sensor [securityjavafrontend]
[INFO] Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=1ms
[INFO] Sensor JavaAndroidConfigurationSensor [securityjavafrontend]
[INFO] Sensor JavaAndroidConfigurationSensor [securityjavafrontend] (done) | time=0ms
[INFO] Sensor JavaModuleSecuritySensor [securityjavafrontend]
[INFO] Sensor JavaModuleSecuritySensor [securityjavafrontend] (done) | time=0ms
[INFO] Sensor SurefireSensor [java]
[INFO] parsing [/var/lib/jenkins/jobs/xxxx/branches/PR-349/workspace/target/surefire-reports]
[INFO] Sensor SurefireSensor [java] (done) | time=81ms
[INFO] Sensor XML Sensor [xml]
[INFO] 2 source files to be analyzed
[INFO] 2/2 source files have been analyzed
[INFO] Sensor XML Sensor [xml] (done) | time=132ms
[INFO] Sensor Java A3S Context Collector [javaa3scontextcollector]
[INFO] Sensor Java A3S Context Collector [javaa3scontextcollector] (done) | time=449ms
[INFO] Sensor DBD/Java IR Generation [dbdjavafrontend]
[INFO] Sensor DBD/Java IR Generation [dbdjavafrontend] (done) | time=78ms
[INFO] Sensor javabugs [dbd]
[INFO] Analyzing 1141/2138 functions to detect bugs.
[INFO] Sensor javabugs [dbd] (done) | time=1872ms
[INFO] Sensor pythonbugs [dbd]
[INFO] No IR files have been included for analysis.
[INFO] Sensor pythonbugs [dbd] (done) | time=1ms
[INFO] Sensor EnterpriseTextAndSecretsSensor [textenterprise]
[INFO] Available processors: 4
[INFO] Using 4 threads for analysis.
[INFO] Start fetching files for the text and secrets analysis
[INFO] Using Git CLI to retrieve dirty files
[WARNING] Retrieving only language associated files, make sure to run the analysis inside a git repository to make use of inclusions specified via "sonar.text.inclusions"
[INFO] Starting the text and secrets analysis
[INFO] 214 source files to be analyzed for the text and secrets analysis
[INFO] 214/214 source files have been analyzed for the text and secrets analysis
[INFO] Start fetching files for the binary file analysis
[INFO] There are no files to be analyzed for the binary file analysis
[INFO] Sensor EnterpriseTextAndSecretsSensor [textenterprise] (done) | time=703ms
[INFO] Sensor JavaSecuritySensor [security]
[INFO] 29 taint analysis rules enabled.
[INFO] Analyzing 1072 UCFGs to detect vulnerabilities.
[INFO] All rules entry points : 4
[INFO] Retained UCFGs : 46
[INFO] 0 / 46 UCFGs simulated, memory usage: 502 MB
[INFO] 43 / 46 UCFGs simulated, memory usage: 546 MB
[INFO] java security sensor: Begin: 2026-05-29T19:15:10.040273858Z, End: 2026-05-29T19:15:12.624285393Z, Duration: 00:00:02.584
  Load type hierarchy and UCFGs: Begin: 2026-05-29T19:15:10.042897136Z, End: 2026-05-29T19:15:10.411988695Z, Duration: 00:00:00.369
    Load type hierarchy: Begin: 2026-05-29T19:15:10.042912644Z, End: 2026-05-29T19:15:10.102996415Z, Duration: 00:00:00.060
    Load UCFGs: Begin: 2026-05-29T19:15:10.103113874Z, End: 2026-05-29T19:15:10.411931371Z, Duration: 00:00:00.308
  Check cache: Begin: 2026-05-29T19:15:10.412072596Z, End: 2026-05-29T19:15:10.412545210Z, Duration: 00:00:00.000
    Load cache: Begin: 2026-05-29T19:15:10.412337536Z, End: 2026-05-29T19:15:10.412350790Z, Duration: 00:00:00.000
  Create runtime call graph: Begin: 2026-05-29T19:15:10.412566924Z, End: 2026-05-29T19:15:10.546082960Z, Duration: 00:00:00.133
    Variable Type Analysis #1: Begin: 2026-05-29T19:15:10.412977284Z, End: 2026-05-29T19:15:10.482252680Z, Duration: 00:00:00.069
      Create runtime type propagation graph: Begin: 2026-05-29T19:15:10.413535692Z, End: 2026-05-29T19:15:10.456487142Z, Duration: 00:00:00.042
      Run SCC (Tarjan) on 8031 nodes: Begin: 2026-05-29T19:15:10.456742304Z, End: 2026-05-29T19:15:10.465886287Z, Duration: 00:00:00.009
      Propagate runtime types to strongly connected components: Begin: 2026-05-29T19:15:10.465983845Z, End: 2026-05-29T19:15:10.482196423Z, Duration: 00:00:00.016
    Variable Type Analysis #2: Begin: 2026-05-29T19:15:10.484856101Z, End: 2026-05-29T19:15:10.544701297Z, Duration: 00:00:00.059
      Create runtime type propagation graph: Begin: 2026-05-29T19:15:10.484862509Z, End: 2026-05-29T19:15:10.527685616Z, Duration: 00:00:00.042
      Run SCC (Tarjan) on 8031 nodes: Begin: 2026-05-29T19:15:10.527753884Z, End: 2026-05-29T19:15:10.534362600Z, Duration: 00:00:00.006
      Propagate runtime types to strongly connected components: Begin: 2026-05-29T19:15:10.534412727Z, End: 2026-05-29T19:15:10.544649470Z, Duration: 00:00:00.010
  Load config: Begin: 2026-05-29T19:15:10.546132441Z, End: 2026-05-29T19:15:12.010800826Z, Duration: 00:00:01.464
  Compute entry points: Begin: 2026-05-29T19:15:12.010919962Z, End: 2026-05-29T19:15:12.078250829Z, Duration: 00:00:00.067
  Slice call graph: Begin: 2026-05-29T19:15:12.078410690Z, End: 2026-05-29T19:15:12.080610836Z, Duration: 00:00:00.002
  Live variable analysis: Begin: 2026-05-29T19:15:12.080677011Z, End: 2026-05-29T19:15:12.104047526Z, Duration: 00:00:00.023
  Taint analysis for java: Begin: 2026-05-29T19:15:12.104241638Z, End: 2026-05-29T19:15:12.523269091Z, Duration: 00:00:00.419
  Report issues: Begin: 2026-05-29T19:15:12.523376630Z, End: 2026-05-29T19:15:12.620462474Z, Duration: 00:00:00.097
  Store cache: Begin: 2026-05-29T19:15:12.620945915Z, End: 2026-05-29T19:15:12.623458455Z, Duration: 00:00:00.002
[INFO] java security sensor peak memory (pre-GC, max allocation pressure): 761 MB
[INFO] java security sensor peak memory (post-GC, max live footprint): 560 MB
[INFO] Sensor JavaSecuritySensor [security] (done) | time=2587ms
[INFO] ------------- Run sensors on project
[INFO] Sensor JaCoCo Aggregate XML Report Importer [jacoco]
[INFO] Sensor JaCoCo Aggregate XML Report Importer [jacoco] (done) | time=0ms
[INFO] Sensor CveReachabilitySensor [cvereachability]
[INFO] Skipping CveReachabilitySensor
[INFO] Sensor CveReachabilitySensor [cvereachability] (done) | time=0ms
[INFO] Sensor javaSecurityContextCollectorSensor [securitya3scontextcollector]
[INFO] Sensor javaSecurityContextCollectorSensor [securitya3scontextcollector] (done) | time=0ms
[INFO] Sensor Java A3S Project Context Collector [javaa3scontextcollector]
[INFO] Sensor Java A3S Project Context Collector [javaa3scontextcollector] (done) | time=0ms
[INFO] Sensor JavaProjectSensor [java]
[INFO] Sensor JavaProjectSensor [java] (done) | time=2ms
[INFO] Sensor JavaArchitectureSensor [architecture]
[INFO] Found 1 potential Udg file location(s) for "java" in "/var/lib/jenkins/jobs/xxxx/branches/PR-349/workspace/target/sonar"
[INFO] - /var/lib/jenkins/jobs/xxxx/branches/PR-349/workspace/target/sonar/architecture/java
[INFO] Architecture analysis is enabled with the following features: legacy, discovery, flaws, smells, deviations, directives
[INFO] * Protobuf reading starting | memory total=860 | free=238 | used=621 (MB)
[INFO] * Reading SonarArchitecture UDG data from directory "/var/lib/jenkins/jobs/xxxx/branches/PR-349/workspace/target/sonar/architecture/java"
[INFO] * Files successfully loaded: "212" out of "212"
[INFO] * Purging externals (components not scanned) from graphs
[INFO] * Purging excluded nodes from graphs
[INFO] * Protobuf reading complete | memory total=860 | free=189 | used=670 (MB)
[INFO] * Build architecture.graph.java.namespace_graph.default_perspective hierarchy graph complete (filtered=false) | memory total=860 | free=175 | used=684 (MB)
[INFO] * No intended architecture defined or detected, using an empty model
[INFO] No directives configured
[INFO] Sensor JavaArchitectureSensor [architecture] (done) | time=665ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=33ms
[INFO] Sensor Java CPD Block Indexer
[INFO] Sensor Java CPD Block Indexer (done) | time=156ms
[INFO] Sensor Architecture Telemetry [architecture]
[INFO] Sensor Architecture Telemetry [architecture] (done) | time=0ms
[INFO] ------------- Gather SCA dependencies on project
[INFO] Dependency analysis skipped
[INFO] CPD Executor 50 files had no CPD blocks
[INFO] CPD Executor Calculating CPD for 118 files
[INFO] CPD Executor CPD calculation finished (done) | time=33ms
[INFO] SCM Publisher SCM provider for this project is: git
[INFO] SCM Publisher 214 source files to be analyzed
[INFO] SCM Publisher 213/214 source files have been analyzed (done) | time=1737ms
[WARNING] Missing blame information for the following files:
[WARNING]   * pom.xml
[WARNING] This may lead to missing/broken features in SonarCloud
[INFO] SCM revision ID '60b700f48b838c17112a0bdfc1e03c8cd51704e6'
[INFO] Analysis report generated in 214ms, dir size=2 MB
[INFO] Analysis report compressed in 288ms, zip size=948 KB
[INFO] Analysis report uploaded in 398ms
[INFO] ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=xxxx
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at https://sonarcloud.io/api/ce/task?id=xxxx
[INFO] Successfully sent architecture data
[INFO] ------------- Upload SCA dependency files
[INFO] Sensor cache published successfully
[INFO] Analysis total time: 42.864 s
[INFO] SonarScanner Engine completed successfully
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:16 min

Hello Dan and welcome to the Sonar community!

To detect a PR/branch analysis, the SonarScanner for Jenkins is looking for some environment variables that are normally set by the Bitbucket branch plugin:

  • CHANGE_BRANCH, CHANGE_ID and CHANGE_TARGET for PR analyses.
  • BRANCH_NAME for branch analyses.

You could try printing them from the exact step/container where the SonarScanner runs. It’s possible in your case, they are somehow not being propagated from the step where the Bitbucket plugin runs.