Need to analyze branch with name "env/v2/dev-test"

I have a branch name “env/v2/dev-test”, and I want it to be included in Long lived branches on sonar.
The regex I am using is /(^env.*)-*/ and it matches my branch on this website:
There are 4 branches that match this regex in my repository. But I still cannot see my branches with name “env/…” in the branches tab.

Java Spring Boot
Java 17

Additional questions:
Do I have run the pipeline every time after updating the regex?
Does my pipeline script need to updated in all the branches? BTW it scanned master without any update in the pipeline, so I assumed I dont need to include pipeline code in every branch.


What version of SonarQube are you using? If you’re not sure, you can check your page footer.

SonarQube hasn’t had short-lived branches for quite a while now, and thus on current versions all branches are long-lived.



I cannot see any version in the footer.

I was able to add as short lived branch, but I need it as long live branch.


Your best bet here is to upgrade. Not being sure where you’re starting from, I can only guess at your upgrade path, but you must hit every LTA release between where you are and the current version. E.G.

7.9.6 → 8.9.10 → 9.9.4 → 10.5 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.


I am using Sonar cloud, and the latest version of it. How do I upgrade?


Thanks for that update. I’ve recategorized your thread to SonarCloud.

Since you are on SonarCloud, there’s no need to upgrade.

You’ll want to edit your long-lived branch pattern to a regex that matches your branch name. You say you tested your regex against, but it seems that that site expects you to use regex delimiters: leading and trailing forward slashes. SonarCloud doesn’t need any delimiters; the whole input is the regex. So as a first step, I would trim off those slashes. That gets us to


What that describes is a string that starts with env followed by any number of any character (.*), followed by any number of dashes (-*). And that doesn’t match the branch name string you’re using. To match that branch name, something like this would work:


However, that would exclude branches without that prefix.

No. It’s worth being very explicit here that a branch’s type is set on its first analysis and is then immutable. So you could theoretically set a pattern that exactly matches your branch name, analyze that branch, and then reset the pattern. Your already-analyzed branch will be unaffected at its next analysis.

Note also, that to get your env* branch set up as a long-lived branch, you’ll need to first delete it from SonarCloud if it currently exists there, and re-create it.


I narrowed down the regex to (^env/v2/.)-
This only deals with branches that look like env/v2/dev*.
The branch I am trying to analyse is env/v2/dev-aws-pipe.
Below is a screenshot of how I added it into my sonar cloud.
But it is only putting it in short lived branch.

BTW I have also tried the exact string, it does not work either


I’ll be honest and say I’m not sure we expected path delimiters in branch names when this was built. Could you try

  • setting the regex to env*
  • replacing the /s in the branch name with maybe -s



Hiya, Actualy the regex was working but my due to cache the project updated were not being scanned. I removed cache and it works fine now, a little slow but that is fine as I don’t runt he pipeline daily.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.