Sonarqube + sonar-scm-git + TeamCity + Maven scm config = "doesn't seem to be contained in a Git repository"

1,243 views
Skip to first unread message

thomas...@googlemail.com

unread,
Jan 8, 2016, 7:23:30 AM1/8/16
to SonarQube
Hi,

after trying to setup our project to use SonarQube we are facing the following bug/error.

Setup:
1.) Build-Tool TeamCity -> Checks out remote git repo and transfers the source to the buildagent server
2.) The source on the buildagent doesn't contain the .git repository!
3.) Maven is started on the buildagent server with goal sonar:sonar
4.) Maven's pom.xml contains <scm> section with <connection>scm:git:xxx</connection>

I think the problem is that ScmConfiguration.starrt() is called. autodetection() doesn't detect any SCM provider, then considerOldScmUrl() is called which seems to process Maven's <scm> section. The call to considerOldScmUrl() detects git as SCM provider.

Problem is that the sonar-scm-git assumes that the build directory is equal to the git work directory which isn't the case for our setup. Also Maven's <connection> URL points correctly to the remote git repository.

I think the correct fix would be to call the blame command on the git URL pointed to by Maven's <scm> entry. But I don't know if this is possible technically with git SCM and jgit to call a blame command on a bare remote repository.

If it is technically possible please also consider this:

Sadly our git repo lies behind a HTTPS proxy and needs username and password to authenticate.
So Maven's settings.xml <server> section (for username and password) and <proxies> section (for all relevant proxies) should be evaluated by the sonar-maven-plugin.
The <proxies> section doesn't seem to be considers at all by the current sonar-maven-plugin version 2.7.1, so you need to run Maven with comand line option -Dhttps.proxyHost= and -Dhttps.proxyPort. The correct thing would be to use Maven's internal URL/HTTP/PROXY call mechanism so the <proxies> entry is considered everywhere correctly for HTTP calls.

With kind regards
Thomas Meyer

thomas...@googlemail.com

unread,
Jan 8, 2016, 7:35:22 AM1/8/16
to SonarQube, thomas...@googlemail.com
Hi,

Okay, there seems to be a TeamCity option called "VCS checkout mode", which can be set so the checkout is done on the buildagent.
I'll try that, sorry for the fuss!

Julien HENRY

unread,
Jan 8, 2016, 7:48:54 AM1/8/16
to SonarQube, thomas...@googlemail.com
Hi Thomas,

That's an interesting feedback. Indeed you have spotted all the logic: we need the .git folder to be able to run the blame.

++

Julien
Reply all
Reply to author
Forward
0 new messages