Sonarqube Branch does not exist on server

纵然是瞬间 提交于 2019-12-11 04:17:21

问题


When I try to analyze my project using sonar-scanner, the scan fails with the following error message:

Caused by: Branch does not exist on server: develop

Apparently, this only happens when it analyzes a Pull Request from GitHub. I could reproduce the error, when I add the following configuration to sonar-project.properties:

sonar.branch.name = source-branch
sonar.branch.target = target-branch

What could be the cause for this problem?


回答1:


I solved the problem by deleting my Sonar project that was watching the develop branch. Then I added the develop branch as a long-living branch to the Sonar project analyzing the master branch. Before, I had a Sonar project for each long-living branch, because I was using the branches property in travis.yml (which is getting deprecated now).

To add a new branch to Sonarqube you need to add the sonar.branch.name property with the name of the desired branch to the sonar-project.properties file. E.g.: sonar.branch.name=develop

Then you run sonar-scanner and your branch will be available inside the Sonar-Project.*

* Make sure to check if the Regex for long-living branches is appropriate to your new branch on Sonarqube. You can't change a long-living branch to a short-living branch or vice-versa after the branch is added to Sonarqube.

The result is that I have only one project on Sonarqube now that watches all my branches. It's a lot cleaner and works better.

More information on the branch plugin.



来源:https://stackoverflow.com/questions/49634655/sonarqube-branch-does-not-exist-on-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!