Azure Devops with Git enterprise configuration issues

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    7.9, I think we have most of the plugins installed.

  • what are you trying to achieve
    I am trying to get SonarQube to work with Azure Devops, but always get weirdness… I must have my confif wrong…

  • what have you tried so far to achieve this
    Everything! - but here is my config

    • task: SonarSource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@4
      displayName: ‘Prepare analysis on SonarQube Pull Requests’
      condition: and (
      eq(variables[‘Build.Reason’], ‘PullRequest’),
      ne(variables[‘Build.SourceBranch’], ‘refs/heads/dev’)
      SonarQube: SonarQube
      projectKey: hram
      projectName: hram-upgrade
      projectVersion: '(Build.BuildId)' extraProperties: | sonar.sourceEncoding=UTF-8 sonar.tsql.file.suffixes=.tsql,.sql<CI URL> sonar.links.scm=<REPO URL> sonar.links.issues=<ISSUES URL> sonar.scm.provider=git sonar.cs.vscoveragexml.reportsPaths=**/*.coveragexml sonar.pullrequest.key=(System.PullRequest.PullRequestNumber)
      sonar.pullrequest.base=refs/heads/(System.PullRequest.TargetBranch) sonar.pullrequest.branch=refs/heads/(System.PullRequest.SourceBranch)
      sonar.github.repository=(Build.Repository.Name) sonar.github.pullRequest=(System.PullRequest.PullRequestNumber)

    • task: SonarSource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@4
      displayName: ‘Prepare analysis on SonarQube’
      condition: ne(variables[‘Build.Reason’], ‘PullRequest’)
      SonarQube: SonarQube
      projectKey: hram
      projectName: hram-upgrade
      projectVersion: ‘$(Build.BuildId)’
      extraProperties: |

Some of the behaviours i see is;

  1. The PR decoration doesnt work;
  2. Quite often nothing gets flagged between source and target
  3. When manually running a branch, it will fail with null exception

Any pointers would be great!

Hello Nick and welcome to our forum!

Which edition of SonarQube are you using ?
PR decoration is only available starting from the Developer Edition.

I’m not sure I understand what you mean by that. Could you please elaborate ?

Could you please share the exact scenario and full logs to get a better idea of what could go wrong.


Hey Christophe

Sorry for the delay in reply! - and thansk fro getting back to me!

Version: Enterprise Edition Version 7.9 (build 26994)

So for Number 2 - We quite often see this

But its weird, as I know theres thousands of new lines of code in that PR… so for it to show nothing is odd.

I have also been seeing this alot recently;

In terms of the NullException, if i see it again i will attach a log.

Hope you can help.

Hello Nick,

Regarding PR:
Looking at your config, you should remove all sonar.pullrequest:* properties from there. They are incorrect and these properties should be handled automatically by the SonarScanner for Azure Devops extension.
You should be able to find all additional information on the Branch and Pull Request analysis section of the SonarQube SonarScanner for Azure DevOps documentation page.

This should fix your issue with PR integration.

=> Thanks.

Hard to day what is wrong there, it seems different branches (/projects?) are considered as baseline at different moment in times. Do you know what changed in december in your CI that could cause this ?