# Sonarqube New Code Analysis is always empty

**URL:** <https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398>\
**Category:** SonarQube Server / Community Build\
**Tags:** sonarqube\
**Created:** [May 8, 2020, 8:21pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398 "2020-05-08T20:21:38Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![apar](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@apar](https://community.sonarsource.com/u/apar)\
**Post date:** [May 8, 2020, 8:21pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/1 "2020-05-08T20:21:38Z")

</div>

Sonarqube developer version: **8.2.0.32929**

We are trying to get New Code analysis done on Pull Request branches. I have read the [fixing the water leak article](https://sonarcloud.io/documentation/user-guide/fixing-the-water-leak/) as well as the concepts of [Long-Lived Branches](https://sonarcloud.io/documentation/branches/long-lived-branches/) and [Short-Lived Branches](https://sonarcloud.io/documentation/branches/short-lived-branches/)

I wanted to ask if fundamentally the following is possible in Sonarqube. When a pull request is created on a specific branch say feature/aa targeting master, can we see the code analysis done on only the new code which was added in the branch?

We have tried this by doing the following –

- Doing a normal branch analysis with following args -  
sonar-scanner   
-Dsonar.pullrequest.key={PULL\_REQUEST\_NUMBER} \ -Dsonar.pullrequest.branch=PR-{PULL\_REQUEST\_NUMBER}   
-Dsonar.pullrequest.base=${PULL\_REQUEST\_BASE\_REF}   
…
- Created a rule for long running branches with `feature/*` rule and created a PR with a branch name of `feature/sonarqube-test` added some minor issues and created the PR. Even in this case, the new code doesn’t show

We always end up seeing an image like following –

 ![Screen Shot 2020-05-08 at 1.18.27 PM](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/d/d4fb517142e3cfc05a74abaa82edfee7a2642336.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 9, 2020, 9:30am UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/2 "2020-05-09T09:30:44Z")

</div>

> [@apar](#):
>
> sonar-scanner  
> -Dsonar.pullrequest.key={PULL\_REQUEST\_NUMBER} \ -Dsonar.pullrequest.branch=PR-{PULL\_REQUEST\_NUMBER}  
> -Dsonar.pullrequest.base=${PULL\_REQUEST\_BASE\_REF}

It’s odd that you have PULL\_REQUEST\_NUMBER as both the variable for `sonar.pullrequest.key` and `sonar.pullrequest.branch`.

The latter (`sonar.pullrequest.branch`) should be equivalent to the name of the branch you want to merge into the branch defined by `sonar.pullrequest.base`.

I would expect the detection of changed files/lines to work better if that is resolved.

Out of curiosity, what CI tool are you typically using? These parameters should be auto-configured in many cases, which is much less error prone.

---

<div class="post-metadata">

**Author:** ![apar](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@apar](https://community.sonarsource.com/u/apar)\
**Post date:** [May 11, 2020, 9:46pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/3 "2020-05-11T21:46:13Z")

</div>

The branch is actually PR-{PULL\_REQUEST\_NUMBER} and this seems to be populated just fine actual branch analysis. I can also navigate from the branch analysis to actual PR in GitHub.

Regarding CI tool, we use Jenkins pipeline for CI and pass these params as part of a build pipeline. Let me know if there is a better way to do this.

---

<div class="post-metadata">

**Author:** ![apar](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@apar](https://community.sonarsource.com/u/apar)\
**Post date:** [May 11, 2020, 9:50pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/4 "2020-05-11T21:50:17Z")

</div>

Here is the screenshot for the branch information for the analysis above.

---

<div class="post-metadata">

**Author:** ![apar](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@apar](https://community.sonarsource.com/u/apar)\
**Post date:** [May 18, 2020, 5:31pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/5 "2020-05-18T17:31:44Z")

</div>

Hi Colin it seems to work fine for the branch name, seems to be loaded just fine in the Sonar UI as well. The parameters being passed are something on the lines of –

```
-Dsonar.pullrequest.key=2000 \ 
-Dsonar.pullrequest.branch=PR-2000 \ 
-Dsonar.pullrequest.base=master

```

 ![Screen Shot 2020-05-11 at 2.48.29 PM](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/e/e787eaf23e138b356969a6429ac958b649f75717.png)

---

<div class="post-metadata">

**Author:** ![apar](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@apar](https://community.sonarsource.com/u/apar)\
**Post date:** [May 18, 2020, 5:32pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/6 "2020-05-18T17:32:22Z")

</div>

![Screen Shot 2020-05-11 at 2.53.00 PM](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/0/0c3b5023119c60c0b14f22aaf152ffa92d337053.png)

---

<div class="post-metadata">

**Author:** ![Daniyal\_Raza](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/daniyal_raza/32/5552_2.png) [@Daniyal\_Raza](https://community.sonarsource.com/u/Daniyal_Raza)\
**Post date:** [May 18, 2020, 8:31pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/7 "2020-05-18T20:31:37Z")

</div>

I’m having the same issue. The branch analysis is working as expected but the PR analysis is empty.

 ![Screenshot 2020-05-19 at 1.08.10 AM](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/0/0b9ccacfcb0b7dec14c8ad281ad31b81cc437c5b.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 21, 2020, 4:44pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/8 "2020-05-21T16:44:54Z")

</div>

> [@apar](#):
>
> Regarding CI tool, we use Jenkins pipeline for CI and pass these params as part of a build pipeline. Let me know if there is a better way to do this.

Since you’re using Jenkins, I’d _highly_ recommend upgrading to 8.3 where these parameters are auto configured.

> [@apar](#):
>
> The branch is actually PR-{PULL\_REQUEST\_NUMBER} and this seems to be populated just fine actual branch analysis. I can also navigate from the branch analysis to actual PR in GitHub.

I’m a bit skeptical about this. In your original post you mentioned feature/sonarqube-test as the branch. This is the value I’d expect to be used for the branch parameter. I could be wrong, but I’m not sure how the detection of new code works if it’s a secondary “merge” branch.

Any other clues would probably be in your analysis logs (with DEBUG logging enabled. Usually achieved by appending ‘-X’ to the scan command). You can attach them in a post on this topic. Specifically, log messages like this are meaningful.

```
13:55:10 - 08:25:10.540 INFO: Pull request 455 for merge into master-branch from pr-branch
13:55:10 - 08:25:10.552 INFO: SCM collecting changed files in the branch
13:55:10 - 08:25:10.611 DEBUG: readpipe [git, --version],/usr/bin
13:55:10 - 08:25:10.623 DEBUG: readpipe may return ‘git version 2.9.3’
13:55:10 - 08:25:10.623 DEBUG: remaining output:
13:55:10 -
13:55:10 - 08:25:10.623 DEBUG: readpipe [git, config, --system, --edit],/usr/bin
13:55:10 - 08:25:10.626 DEBUG: readpipe may return ‘/etc/gitconfig’
13:55:10 - 08:25:10.626 DEBUG: remaining output:
13:55:10 -
13:55:10 - 08:25:10.744 DEBUG: Merge base sha1: 8888888888888888888
13:55:10 - 08:25:10.768 INFO: SCM collecting changed files in the branch (done) | time=216ms
**13:55:10 - 08:25:10.768 DEBUG: SCM reported 0 files changed in the branch**

```

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 21, 2020, 4:46pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/9 "2020-05-21T16:46:35Z")

</div>

> [@Daniyal\_Raza](#):
>
> I’m having the same issue. The branch analysis is working as expected but the PR analysis is empty.

I’d recommend starting a new thread with more details. Troubleshooting multiple, even related, problems on one community post is messy 🙂

---

<div class="post-metadata">

**Author:** ![apar](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@apar](https://community.sonarsource.com/u/apar)\
**Post date:** [May 27, 2020, 4:58pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/10 "2020-05-27T16:58:12Z")

</div>

Hi Colin, I was able to update the sonar server to 8.3. But I am not seeing any changes in the analysis. I enabled debug logs like you suggested and I am seeing logs like you mentioned -

```
[2020-05-27T16:40:35.766Z] 16:40:35.559 INFO: Pull request 3756 for merge into master from PR-3756
[2020-05-27T16:40:35.766Z] 16:40:35.589 INFO: SCM collecting changed files in the branch
[2020-05-27T16:40:35.766Z] 16:40:35.616 DEBUG: file=<workspace>/.git/config, create new FileSnapshot: lastRead=2020-05-27 16:40:35.614000000, lastModified=2020-05-27 16:40:31.397891000, size=199, fileKey=(dev=10302,ino=64256003)
[2020-05-27T16:40:35.766Z] 16:40:35.620 DEBUG: file=null, size changed from -1 to 146 bytes
[2020-05-27T16:40:35.766Z] 16:40:35.620 DEBUG: loading config FileBasedConfig[/root/.config/jgit/config]
[2020-05-27T16:40:35.766Z] 16:40:35.621 DEBUG: file=/root/.config/jgit/config, create new FileSnapshot: lastRead=2020-05-27 16:40:35.620000000, lastModified=2020-05-26 16:51:58.489008000, size=146, fileKey=(dev=34,ino=80656636)
[2020-05-27T16:40:35.766Z] 16:40:35.622 DEBUG: readpipe [git, --version],/usr/bin
[2020-05-27T16:40:35.766Z] 16:40:35.654 DEBUG: readpipe may return 'git version 2.17.1'
[2020-05-27T16:40:35.766Z] 16:40:35.654 DEBUG: remaining output:
[2020-05-27T16:40:35.766Z] 
[2020-05-27T16:40:35.766Z] 16:40:35.655 DEBUG: readpipe [git, config, --system, --edit],/usr/bin
[2020-05-27T16:40:35.766Z] 16:40:35.659 DEBUG: readpipe may return '/etc/gitconfig'
[2020-05-27T16:40:35.766Z] 16:40:35.659 DEBUG: remaining output:
[2020-05-27T16:40:35.766Z] 
[2020-05-27T16:40:35.766Z] 16:40:35.659 DEBUG: file=/root/.config/jgit/config, isRacyClean=false, read=2020-05-27 16:40:35.620000000, lastModified=2020-05-26 16:51:58.489008000, delta=85717130992000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.766Z] 16:40:35.659 DEBUG: file=/root/.config/jgit/config, is unmodified
[2020-05-27T16:40:35.766Z] 16:40:35.660 DEBUG: file=null, size changed from -1 to 0 bytes
[2020-05-27T16:40:35.767Z] 16:40:35.660 DEBUG: loading config FileBasedConfig[/etc/gitconfig]
[2020-05-27T16:40:35.767Z] 16:40:35.660 DEBUG: file=/root/.config/jgit/config, isRacyClean=false, read=2020-05-27 16:40:35.620000000, lastModified=2020-05-26 16:51:58.489008000, delta=85717130992000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.660 DEBUG: file=/root/.config/jgit/config, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.660 DEBUG: file=/etc/gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=1970-01-01 00:00:00.000000000, delta=1590597635660000000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.660 DEBUG: file=/etc/gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.660 DEBUG: file=null, size changed from -1 to 48 bytes
[2020-05-27T16:40:35.767Z] 16:40:35.660 DEBUG: loading config FileBasedConfig[/root/.gitconfig]
[2020-05-27T16:40:35.767Z] 16:40:35.660 DEBUG: file=/root/.gitconfig, create new FileSnapshot: lastRead=2020-05-27 16:40:35.660000000, lastModified=2020-05-27 16:40:31.709893000, size=48, fileKey=(dev=34,ino=80646929)
[2020-05-27T16:40:35.767Z] 16:40:35.661 DEBUG: file=<workspace>/.git/config, create new FileSnapshot: lastRead=2020-05-27 16:40:35.661000000, lastModified=2020-05-27 16:40:31.397891000, size=199, fileKey=(dev=10302,ino=64256003)
[2020-05-27T16:40:35.767Z] 16:40:35.662 DEBUG: file=/root/.config/jgit/config, isRacyClean=false, read=2020-05-27 16:40:35.620000000, lastModified=2020-05-26 16:51:58.489008000, delta=85717130992000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.662 DEBUG: file=/root/.config/jgit/config, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.662 DEBUG: file=/etc/gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=1970-01-01 00:00:00.000000000, delta=1590597635660000000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.662 DEBUG: file=/etc/gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.663 DEBUG: file=/root/.gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=2020-05-27 16:40:31.709893000, delta=3950107000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.663 DEBUG: file=/root/.gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.663 DEBUG: file=<workspace>/.git/config, isRacyClean=false, read=2020-05-27 16:40:35.661000000, lastModified=2020-05-27 16:40:31.397891000, delta=4263109000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.663 DEBUG: file=<workspace>/.git/config, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.694 DEBUG: file=/root/.config/jgit/config, isRacyClean=false, read=2020-05-27 16:40:35.620000000, lastModified=2020-05-26 16:51:58.489008000, delta=85717130992000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.694 DEBUG: file=/root/.config/jgit/config, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.694 DEBUG: file=/etc/gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=1970-01-01 00:00:00.000000000, delta=1590597635660000000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.694 DEBUG: file=/etc/gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.695 DEBUG: file=/root/.gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=2020-05-27 16:40:31.709893000, delta=3950107000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.695 DEBUG: file=/root/.gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.696 DEBUG: file=<workspace>/.git/index, create new FileSnapshot: lastRead=2020-05-27 16:40:35.683000000, lastModified=2020-05-27 16:40:33.173906000, size=3907090, fileKey=(dev=10302,ino=64256020)
[2020-05-27T16:40:35.767Z] 16:40:35.696 DEBUG: file=/root/.config/jgit/config, isRacyClean=false, read=2020-05-27 16:40:35.620000000, lastModified=2020-05-26 16:51:58.489008000, delta=85717130992000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.696 DEBUG: file=/root/.config/jgit/config, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.696 DEBUG: file=/etc/gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=1970-01-01 00:00:00.000000000, delta=1590597635660000000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.696 DEBUG: file=/etc/gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.696 DEBUG: file=/root/.gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=2020-05-27 16:40:31.709893000, delta=3950107000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.696 DEBUG: file=/root/.gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.696 DEBUG: file=<workspace>/.git/config, isRacyClean=false, read=2020-05-27 16:40:35.661000000, lastModified=2020-05-27 16:40:31.397891000, delta=4263109000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.696 DEBUG: file=<workspace>/.git/config, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.697 DEBUG: file=<workspace>/.git/refs/heads/master, create new FileSnapshot: lastRead=2020-05-27 16:40:35.696000000, lastModified=2020-05-27 16:40:33.177906000, size=41, fileKey=(dev=10302,ino=64256023)
[2020-05-27T16:40:35.767Z] 16:40:35.698 DEBUG: file=/root/.config/jgit/config, isRacyClean=false, read=2020-05-27 16:40:35.620000000, lastModified=2020-05-26 16:51:58.489008000, delta=85717130992000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.698 DEBUG: file=/root/.config/jgit/config, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.698 DEBUG: file=/etc/gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=1970-01-01 00:00:00.000000000, delta=1590597635660000000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.698 DEBUG: file=/etc/gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.699 DEBUG: file=/root/.gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=2020-05-27 16:40:31.709893000, delta=3950107000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.699 DEBUG: file=/root/.gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.699 DEBUG: file=<workspace>/.git/config, isRacyClean=false, read=2020-05-27 16:40:35.661000000, lastModified=2020-05-27 16:40:31.397891000, delta=4263109000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.699 DEBUG: file=<workspace>/.git/config, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.723 DEBUG: file=/root/.config/jgit/config, isRacyClean=false, read=2020-05-27 16:40:35.620000000, lastModified=2020-05-26 16:51:58.489008000, delta=85717130992000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.724 DEBUG: file=/root/.config/jgit/config, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.724 DEBUG: file=/etc/gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=1970-01-01 00:00:00.000000000, delta=1590597635660000000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.724 DEBUG: file=/etc/gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.724 DEBUG: file=/root/.gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=2020-05-27 16:40:31.709893000, delta=3950107000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.724 DEBUG: file=/root/.gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.725 DEBUG: file=/root/.config/jgit/config, isRacyClean=false, read=2020-05-27 16:40:35.620000000, lastModified=2020-05-26 16:51:58.489008000, delta=85717130992000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.725 DEBUG: file=/root/.config/jgit/config, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.725 DEBUG: file=/etc/gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=1970-01-01 00:00:00.000000000, delta=1590597635660000000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.725 DEBUG: file=/etc/gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.725 DEBUG: file=/root/.gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=2020-05-27 16:40:31.709893000, delta=3950107000 ns, racy<=2500000000 ns
[2020-05-27T16:40:35.767Z] 16:40:35.725 DEBUG: file=/root/.gitconfig, is unmodified
[2020-05-27T16:40:35.767Z] 16:40:35.732 DEBUG: file=null, size changed from -1 to 4096 bytes
[2020-05-27T16:40:35.767Z] 16:40:35.732 DEBUG: file=<workspace>/.git/objects/pack, create new FileSnapshot: lastRead=2020-05-27 16:40:35.732000000, lastModified=2020-05-27 04:12:55.253583000, size=4096, fileKey=(dev=10302,ino=64267738)
[2020-05-27T16:40:35.767Z] 16:40:35.737 DEBUG: file=<workspace>/.git/objects/pack/pack-67b5653c768c3636d01d6c781aed9b802f8e1ed8.pack, create new FileSnapshot: lastRead=2020-05-27 16:40:35.736000000, lastModified=2020-05-27 16:40:33.000000000, size=1411923032, fileKey=(dev=10302,ino=64267745)
[2020-05-27T16:40:35.767Z] 16:40:35.737 DEBUG: file=<workspace>/.git/objects/pack/pack-4acaa7be6d34931e3442a4df5739c3f23ba1fe9d.pack, create new FileSnapshot: lastRead=2020-05-27 16:40:35.737000000, lastModified=2020-05-27 16:40:33.000000000, size=68515, fileKey=(dev=10302,ino=64277770)
[2020-05-27T16:40:35.767Z] 16:40:35.737 DEBUG: file=<workspace>/.git/objects/pack/pack-896c291ac7269c1fb2b241c533337a63b93e34bd.pack, create new FileSnapshot: lastRead=2020-05-27 16:40:35.737000000, lastModified=2020-05-27 16:40:33.000000000, size=126303, fileKey=(dev=10302,ino=64279639)
[2020-05-27T16:40:35.767Z] 16:40:35.737 DEBUG: file=<workspace>/.git/objects/pack/pack-a9976090065f018e519c001aac001645f330016c.pack, create new FileSnapshot: lastRead=2020-05-27 16:40:35.737000000, lastModified=2020-05-27 16:40:33.000000000, size=98971, fileKey=(dev=10302,ino=64279616)
[2020-05-27T16:40:35.767Z] 16:40:35.737 DEBUG: file=<workspace>/.git/objects/pack/pack-ae920801cf07c49f91add6c64f04081b20746738.pack, create new FileSnapshot: lastRead=2020-05-27 16:40:35.737000000, lastModified=2020-05-27 16:40:33.000000000, size=123351, fileKey=(dev=10302,ino=64279594)
[2020-05-27T16:40:36.024Z] 16:40:35.839 DEBUG: Opening pack index <workspace>/.git/objects/pack/pack-67b5653c768c3636d01d6c781aed9b802f8e1ed8.idx, size 37.509 MB took 98 ms
[2020-05-27T16:40:36.024Z] 16:40:35.839 DEBUG: Opening pack index <workspace>/.git/objects/pack/pack-4acaa7be6d34931e3442a4df5739c3f23ba1fe9d.idx, size 0.005 MB took 0 ms
[2020-05-27T16:40:36.024Z] 16:40:35.840 DEBUG: Opening pack index <workspace>/.git/objects/pack/pack-896c291ac7269c1fb2b241c533337a63b93e34bd.idx, size 0.005 MB took 0 ms
[2020-05-27T16:40:36.024Z] 16:40:35.841 DEBUG: Opening pack index <workspace>/.git/objects/pack/pack-a9976090065f018e519c001aac001645f330016c.idx, size 0.005 MB took 1 ms
[2020-05-27T16:40:36.024Z] 16:40:35.842 DEBUG: Opening pack index <workspace>/.git/objects/pack/pack-ae920801cf07c49f91add6c64f04081b20746738.idx, size 0.011 MB took 1 ms
[2020-05-27T16:40:36.024Z] 16:40:35.842 DEBUG: file=<workspace>/.git/objects/pack, isRacyClean=false, read=2020-05-27 16:40:35.732000000, lastModified=2020-05-27 04:12:55.253583000, delta=44860478417000 ns, racy<=14992500 ns
[2020-05-27T16:40:36.024Z] 16:40:35.842 DEBUG: file=<workspace>/.git/objects/pack, is unmodified
[2020-05-27T16:40:36.024Z] 16:40:35.846 DEBUG: file=/root/.config/jgit/config, isRacyClean=false, read=2020-05-27 16:40:35.620000000, lastModified=2020-05-26 16:51:58.489008000, delta=85717130992000 ns, racy<=2500000000 ns
[2020-05-27T16:40:36.024Z] 16:40:35.846 DEBUG: file=/root/.config/jgit/config, is unmodified
[2020-05-27T16:40:36.024Z] 16:40:35.847 DEBUG: file=/etc/gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=1970-01-01 00:00:00.000000000, delta=1590597635660000000 ns, racy<=2500000000 ns
[2020-05-27T16:40:36.024Z] 16:40:35.848 DEBUG: file=/etc/gitconfig, is unmodified
[2020-05-27T16:40:36.024Z] 16:40:35.848 DEBUG: file=/root/.gitconfig, isRacyClean=false, read=2020-05-27 16:40:35.660000000, lastModified=2020-05-27 16:40:31.709893000, delta=3950107000 ns, racy<=2500000000 ns
[2020-05-27T16:40:36.024Z] 16:40:35.848 DEBUG: file=/root/.gitconfig, is unmodified
[2020-05-27T16:40:36.024Z] 16:40:35.848 DEBUG: file=<workspace>/.git/config, isRacyClean=false, read=2020-05-27 16:40:35.661000000, lastModified=2020-05-27 16:40:31.397891000, delta=4263109000 ns, racy<=2500000000 ns
[2020-05-27T16:40:36.024Z] 16:40:35.848 DEBUG: file=<workspace>/.git/config, is unmodified
[2020-05-27T16:40:36.024Z] 16:40:35.849 DEBUG: file=<workspace>/.git/HEAD, create new FileSnapshot: lastRead=2020-05-27 16:40:35.848000000, lastModified=2020-05-27 16:40:31.581892000, size=23, fileKey=(dev=10302,ino=64256006)
[2020-05-27T16:40:36.024Z] 16:40:35.850 DEBUG: file=<workspace>/.git/refs/heads/master, isRacyClean=false, read=2020-05-27 16:40:35.696000000, lastModified=2020-05-27 16:40:33.177906000, delta=2518094000 ns, racy<=14992500 ns
[2020-05-27T16:40:36.024Z] 16:40:35.850 DEBUG: file=<workspace>/.git/refs/heads/master, is unmodified
[2020-05-27T16:40:36.024Z] 16:40:35.851 DEBUG: file=<workspace>/.git/objects/pack, isRacyClean=false, read=2020-05-27 16:40:35.732000000, lastModified=2020-05-27 04:12:55.253583000, delta=44860478417000 ns, racy<=14992500 ns
[2020-05-27T16:40:36.024Z] 16:40:35.851 DEBUG: file=<workspace>/.git/objects/pack, is unmodified
[2020-05-27T16:40:36.024Z] 16:40:35.851 DEBUG: file=<workspace>/.git/objects/pack, isRacyClean=false, read=2020-05-27 16:40:35.732000000, lastModified=2020-05-27 04:12:55.253583000, delta=44860478417000 ns, racy<=14992500 ns
[2020-05-27T16:40:36.024Z] 16:40:35.852 DEBUG: file=<workspace>/.git/objects/pack, is unmodified
[2020-05-27T16:40:36.024Z] 16:40:35.852 DEBUG: Merge base sha1: 8888888888888888888
```

---

<div class="post-metadata">

**Author:** ![apar](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@apar](https://community.sonarsource.com/u/apar)\
**Post date:** [May 27, 2020, 5:01pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/11 "2020-05-27T17:01:06Z")

</div>

I see 2 main things of importance which I would like to point out -  
`[2020-05-27T16:40:36.024Z] 16:40:35.879 DEBUG: SCM reported 0 files changed in the branch`  
` [2020-05-27T16:40:35.512Z] 16:40:35.348 INFO: Found manual configuration of branch/PR analysis. Skipping automatic configuration.`

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 27, 2020, 5:14pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/12 "2020-05-27T17:14:39Z")

</div>

Very important stuff! 🙂

> [@apar](#):
>
> `[2020-05-27T16:40:35.512Z] 16:40:35.348 INFO: Found manual configuration of branch/PR analysis. Skipping automatic configuration.`

Let me suggest first removing any manual configuration you’ve done (the configuration of `sonar.pullrequest.*`). This will allow auto-configuration of those properties to kick in.

Out of curiosity, is there evidence earlier in the logs that there are files actually being analyzed?

---

<div class="post-metadata">

**Author:** ![apar](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@apar](https://community.sonarsource.com/u/apar)\
**Post date:** [May 27, 2020, 5:55pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/13 "2020-05-27T17:55:42Z")

</div>

I tried by removing the params like you suggested –

`<workspace>/SonarQube-Scanner-4.3/bin/sonar-scanner -X -Dsonar.sourceEncoding=UTF-8 -Dsonar.projectKey=<project-key> -Dsonar.projectVersion=2998 -Dsonar.scm.revision=8888888888888888888`

which got populated from –

```
${scannerHome}/bin/sonar-scanner -X \
                -Dsonar.sourceEncoding=UTF-8 \
                -Dsonar.projectKey=<project-key> \
                -Dsonar.projectVersion=${params.BUILD_NUMBER} \
                -Dsonar.scm.revision=${params.PULL_PULL_SHA}

```

This did not end up doing a PR analysis. It ended up on the master branch. I also do not see any logs of the following kind –  
[2020-05-27T16:40:35.766Z] 16:40:35.559 INFO: Pull request 3756 for merge into master from PR-3756  
[2020-05-27T16:40:35.766Z] 16:40:35.589 INFO: SCM collecting changed files in the branch  
[2020-05-27T16:40:36.024Z] 16:40:35.879 DEBUG: SCM reported 0 files changed in the branch  
[2020-05-27T16:40:36.024Z] 16:40:35.852 DEBUG: Merge base sha1: 8888888888888888888

Regarding analysis, I see logs for thousands of files which are –  
`[2020-05-27T17:33:02.190Z] 17:33:01.880 DEBUG: 'filename' indexed with language 'kotlin'`

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 27, 2020, 6:18pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/14 "2020-05-27T18:18:37Z")

</div>

Hm.

> [@apar](#):
>
> Regarding CI tool, we use Jenkins pipeline for CI and pass these params as part of a build pipeline. Let me know if there is a better way to do this.

Is there a chance that you’re using Jenkins **X**? I couldn’t find a reference to any of the environment variables you’re using (like `PULL_PULL_SHA`) except in reference to Jenkins **X**. Unfortunately, there we don’t support the automatic configuration of pull requests (only with traditional Jenkins).

If you _are_ using traditional Jenkins, I’m very curious how it’s setup because it seems… atypical.

I’ve sent you a private message to see if you can provide the full logs privately. I feel like we’re missing some context and without it, we’ll just keep blindly trying things.

---

<div class="post-metadata">

**Author:** ![Nishwal\_Shetty](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/nishwal_shetty/32/21793_2.png) [@Nishwal\_Shetty](https://community.sonarsource.com/u/Nishwal_Shetty)\
**Post date:** [March 10, 2022, 12:47pm UTC](https://community.sonarsource.com/t/sonarqube-new-code-analysis-is-always-empty/24398/17 "2022-03-10T12:47:23Z")

</div>

@apar is the issue fixed for you ? if yes what was the solution ?
