Configuring the sonar-maven plugin in pom.xml

SonarQube version:

I am trying to make the sonar integration in our pipelines handsfree. As part of this, I am configuring the sonar-maven plugin in the parent pom.xml in a profile. This is to relieve developers from the overhead of adding the sonar:sonar etc. tags to their build commands.

What I did so far:
I configured a profile in my pom.xml called buil-sonar. But have the following issues:

  • I am not able to set the sonar.branch to the current branch. What is the best way to do it?
  • Other analysis params like sonar.coverage.jacoco.xmlReportPaths also seem to be not working.
  • I am using maven-jgit-buildnumber-plugin to get the branch name but that doesnt seem to be working either.
    Please find attached a snippet of my pom.xml which contains the profile.

profile.txt (2.3 KB)

Any pointers/suggestions will really help me.

Thanks and Regards,


I have an update on this. I figured that the {env.BRANCH_NAME} variable works as far as branch name is concerned. But the sonar-maven plugin is unable to set the branch name in sonar using this <sonar.branch>{env.BRANCH_NAME}</sonar.branch> property and the xmlReportPaths property.

I also tried <>.
Please let me know.