# Sonarqube 8.1 branch analysis, bring back sonar.branch.target

**URL:** <https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585>\
**Category:** Suggest new features\
**Tags:** sonarqube\
**Created:** [February 3, 2020, 12:34pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585 "2020-02-03T12:34:47Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [December 6, 2021, 8:45am UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/29 "2021-12-06T08:45:12Z")

</div>

Hi Chris,

> [@Chris](#):
>
> If my understanding is correct, you need a way to set the reference branch depending on the branch you are working on, without waiting for the branch to be created and without going into the UI.

exactly! This was possible with the `sonar.branch.target` property.  
Now there’s only the way via web api or Sonarqube web ui, but only for branches that already exist  
(i.e. the problem of @markluebbehuesen in this thread).  
When using pull requests or one setting for all branches, see workaround here

> [@Sonarqube 8.4.1 branch analysis, definition of new ?!](https://community.sonarsource.com/t/sonarqube-8-4-1-branch-analysis-definition-of-new/28169/3):
>
> Think i’ve found a working hack. api/projects/search?projects to check if project already exists api/projects/create if it doesn’t exist api/new\_code\_periods/set?project=$projectkey&type=REFERENCE\_BRANCH&value=master api/new\_code\_periods/set?project=$projectkey&branch=master&type=PREVIOUS\_VERSION run Sonarqube analysis Thought 3. would not be possible if project is newly created in 2. ,but it is. Should also be almost safe for parallel builds and scans of the same project !? A…

all is fine, but there are many projects that don’t use PRs and there are special cases where one  
general reference branch for all branches is not sufficient.

Gilbert

---

<div class="post-metadata">

**Author:** ![harshalpatil2012](https://avatars.discourse-cdn.com/v4/letter/h/ac8455/32.png) [@harshalpatil2012](https://community.sonarsource.com/u/harshalpatil2012)\
**Post date:** [January 20, 2022, 7:00am UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/30 "2022-01-20T07:00:20Z")

</div>

When Sonar Team going to add sonar.branch.target property back?

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [January 20, 2022, 7:52am UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/31 "2022-01-20T07:52:59Z")

</div>

the sooner the better 😀  
But seriously, with a lot of votes for this feature request and a LOT of related postings this problem has gained enough attention from Sonarsource - see @Chris posting above.  
I hope / wish there’s already a solution in the making.

Gilbert

---

<div class="post-metadata">

**Author:** ![harshalpatil2012](https://avatars.discourse-cdn.com/v4/letter/h/ac8455/32.png) [@harshalpatil2012](https://community.sonarsource.com/u/harshalpatil2012)\
**Post date:** [March 28, 2022, 10:50am UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/32 "2022-03-28T10:50:51Z")

</div>

Any idea when this issue will be resolved.

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [March 28, 2022, 10:54am UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/33 "2022-03-28T10:54:34Z")

</div>

i’m no Sonarsourcer and have no glance when this will be implemented.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [March 28, 2022, 11:43am UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/34 "2022-03-28T11:43:18Z")

</div>

Hi all,

These will ship in 9.4 (E.T.A. 4 April):

- [SONAR-16162](https://jira.sonarsource.com/browse/SONAR-16162) Enable New Code based on “reference branch” with a scanner parameter
- [SONAR-16163](https://jira.sonarsource.com/browse/SONAR-16163) Process reference branch set by the scanner in the CE
- [SONAR-16164](https://jira.sonarsource.com/browse/SONAR-16164) Document new scanner parameter ‘sonar.newCode.referenceBranch’

&nbsp;  
🙂  
Ann

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [March 28, 2022, 12:03pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/35 "2022-03-28T12:03:13Z")

</div>

Hi Ann,

great news 🥳

though much more to write 😉  
sonar.newCode.referenceBranch = length 33  
sonar.branch.target = length 23

From the descriptions in Jira it seems to be not different from old sonar.branch.target  
behaviour beside the name.

Gilbert

---

<div class="post-metadata">

**Author:** ![petermbauer](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/petermbauer/32/1757_2.png) [@petermbauer](https://community.sonarsource.com/u/petermbauer)\
**Post date:** [March 28, 2022, 2:52pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/36 "2022-03-28T14:52:49Z")

</div>

Thx, great news indeed!

> sonar.newCode.referenceBranch = length 33  
> sonar.branch.target = length 23

what does this mean?

g,  
Peter

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [March 28, 2022, 3:21pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/37 "2022-03-28T15:21:25Z")

</div>

He’s just saying it’s more typing to get the same effect. 🙂

Just consider the new, longer name a sop to our pride. 😉

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![John\_Bain](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/john_bain/32/3668_2.png) [@John\_Bain](https://community.sonarsource.com/u/John_Bain)\
**Post date:** [June 1, 2022, 1:32pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/38 "2022-06-01T13:32:08Z")

</div>

sonar.newCode.referenceBranch = length 33  
sonar.branch.target = length 23

^^^ There is zero equivalence, according to Sonar documentation, for these two properties. Why would you misconstrue, and conflate this? Again, deprecating sonar.branch.target is the most inane, and unconsidered approach SonarQube could do for VERY large enterprise organizations, whom have created implementations based on their delivery model, and SonarQube’s properties. I will be advocating for another solution now. Even though I loved SonarQube over our bespoke, and costly implementation of Coverity, this deprecation of a very basic feature could potentially cost our organization millions. I’m still unsure why Sonar has removed such a simple way to generate a delta based on a branch to be integrated to. I’ve explained enough in my previous comments on this thread as to why this feature change will hurt us. So, we’re kind of stuck.

---

<div class="post-metadata">

**Author:** ![John\_Bain](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/john_bain/32/3668_2.png) [@John\_Bain](https://community.sonarsource.com/u/John_Bain)\
**Post date:** [June 1, 2022, 1:35pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/39 "2022-06-01T13:35:04Z")

</div>

How is that a solution? It is not the same. Please elaborate on implementation? We just upgraded to 8.9.6, and are now facing serious consequences.

---

<div class="post-metadata">

**Author:** ![John\_Bain](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/john_bain/32/3668_2.png) [@John\_Bain](https://community.sonarsource.com/u/John_Bain)\
**Post date:** [June 9, 2022, 3:03pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/40 "2022-06-09T15:03:54Z")

</div>

This is a singular case example. which may work in your implementation, however, I can pretty much guarantee that many organizations will not have this type of integration. Previously, sonar.branch.target was simple to implement, and ensured that new code was analyzed against a delta of the specified target branch in question, rather than a more generalized, and defined common base target branch (e.g. “master”). This implementation fails when it comes to maintenance releases.

---

<div class="post-metadata">

**Author:** ![Chris](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/chris/32/71589_2.png) [@Chris](https://community.sonarsource.com/u/Chris)\
**Post date:** [June 9, 2022, 4:01pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/41 "2022-06-09T16:01:56Z")

</div>

Hi John,

We’ve recently added the possibility to set a reference branch depending on the branch you are working on.  
The parameter is not the same because the management of branches changed since the time we had short-lived branches. Since SonarQube 8.1, the concept for branches was simplified: short-lived and long-lived branches are just branches. Also, choosing a branch as a reference is considered a way to define the New Code on your working branch.  
Can you please explain your use case if this still does not answer your need?

Chris

---

<div class="post-metadata">

**Author:** ![John\_Bain](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/john_bain/32/3668_2.png) [@John\_Bain](https://community.sonarsource.com/u/John_Bain)\
**Post date:** [June 9, 2022, 7:47pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/42 "2022-06-09T19:47:29Z")

</div>

Here is my case: We are a very large enterprise organization currently using SonarQube version 8.9.6 (recently upgraded from 7.9). I noticed that a critical aspect of our implementation was now missing, the sonar.branch.target property, after the upgrade. We have a monolithic codebase consisting of over 850 components/modules (550 are Java, 300+ are native), each one receiving their own project in SonarQube. We do have an integrated tool chain; however, our Sonar is integrated into our build architecture, and implemented via a custom ant solution (I’ll avoid all the details here, though). Since our organization is contracted to support maintenance releases for many major enterprise customers, we also need the ability to control how a given branch’s delta is derived against its relative integration branch (there is only one), or release branch (many). Because of this, we need a method to automate the setting of a newly defined reference branch at compile time, for each module/sonar project, we analyze. After doing more research, I was able to find that using the sonar.newCode.referenceBranch does seem to provide the necessary feature we need, by setting this property each time we would be able to compile a component in our code base (again, I’m not going into to much detail as I am refactoring this incredibly complex build architecture soon) and set the new code period for the “long lived” branch specified now as the reference branch; however, that property isn’t actually available unless we upgrade to at least version 9.4 (per documentation). Unfortunately, I don’t manage the upgrades, but I do have some sway in the solution our company goes with, because our internal org represents the largest profit generator there. Hope that helps you understand our case. In terms of the management of branches, after version 8.1, it seems that SonarQube made many assumptions of how very large organizations manage software releases, and maintenance; which I find to be wrong, in several enterprise cases. Unless, of course, a dev org only needs to be concerned with the newest release, always. In our case, we may have a release branch which currently can live on in perpetuity, thereby breaking this assumption.

---

<div class="post-metadata">

**Author:** ![John\_Bain](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/john_bain/32/3668_2.png) [@John\_Bain](https://community.sonarsource.com/u/John_Bain)\
**Post date:** [June 9, 2022, 7:52pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/43 "2022-06-09T19:52:07Z")

</div>

By the way, we also have a group that creates a custom OS, which also follows a similar model, yet it is multi-repo based. When using Sonar 7.9, we also implemented the sonar.branch.target property for this group, as well.

---

<div class="post-metadata">

**Author:** ![John\_Bain](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/john_bain/32/3668_2.png) [@John\_Bain](https://community.sonarsource.com/u/John_Bain)\
**Post date:** [June 9, 2022, 7:53pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/44 "2022-06-09T19:53:51Z")

</div>

Oh yes, one more thing. I should at least mention that when we moved from Coverity to SonarQube, I was one of the biggest proponents internally driving that. I love what SonarQube provided us at that time, relatively speaking.

---

<div class="post-metadata">

**Author:** ![Chris](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/chris/32/71589_2.png) [@Chris](https://community.sonarsource.com/u/Chris)\
**Post date:** [June 10, 2022, 8:29am UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/45 "2022-06-10T08:29:24Z")

</div>

Thanks for sharing John.  
We try to make SonarQube friendly with the way of working in large organizations. I can understand your need and unfortunately, this new code definition is a major change that was added after the 8.9 LTS. Happy to read that the new configuration will meet your expectations.

---

<div class="post-metadata">

**Author:** ![John\_Bain](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/john_bain/32/3668_2.png) [@John\_Bain](https://community.sonarsource.com/u/John_Bain)\
**Post date:** [June 15, 2022, 6:13pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/46 "2022-06-15T18:13:10Z")

</div>

It does, we just have to upgrade to the 9.4 version to get it, unfortunately. Do you happen to know if there is a maintenance release off of 8.X.X with this new feature?

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [June 15, 2022, 6:48pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/47 "2022-06-15T18:48:50Z")

</div>

Hi,

There’s not. The LTS isn’t updated for new features. Only significant bugs and vulnerabilities.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [June 15, 2022, 7:10pm UTC](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585/48 "2022-06-15T19:10:46Z")

</div>

Hi,

we use Sonarqube Enterprise edition.  
I’ve decided to go with the latest Sonarqube version in 2017 to be able to use the latest / new features.  
Beside some problems with early 8.x versions we never faced any problems.  
As now it ain’t possible to update language scanner plugins - i.e. Sonar Java - without updating your Sonarqube instance, it’s IMO mandatory to go with the latest Sonarqube version if you need to support the latest i.e. typescript/javascript … syntax.  
As Enterprise customer since 2016 i recommend to go with the latest version instead of LTS (every 18 month) to use the most recent language scanner plugins.

Gilbert

[Previous page](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585.md?page=1)

[Next page](https://community.sonarsource.com/t/sonarqube-8-1-branch-analysis-bring-back-sonar-branch-target/19585.md?page=3)
