5

Since sonar switched to using SVNKit I can't get the blame analysis to work for working copies using svn+ssh. It fails with:

[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project example: Error when executing blame for file src/main/java/com/acme/Foo.java: svn: E170001: Authentication required for 'svn@svn+ssh://svn.acme.com' 

The svn command works properly when invoked from command line, also connecting to ssh svn@svn.acme.com succeeds. I'm using SVNKit in Eclipse with this repository and it also works fine (although I had to tell it where to look for private key).

When I'm trying to debug the sonar runner execution I see the private key is simply not set:

myPreviousAuthentication    SVNSSHAuthentication  (id=392)  
    myAgentProxy    null    
    myIsPartial false   
    myIsStorageAllowed  false   
    myKind  "svn.ssh" (id=387)  
    myPassphrase    null    
    myPassword  (id=608)    
    myPortNumber    -1  
    myPrivateKeyFile    null    
    myPrivateKeyValue   null    
    myURL   SVNURL  (id=345)    
    myUserName  "jbochenski" (id=610)   
myPreviousErrorMessage  SVNErrorMessage  (id=388)   
    dontShowErrorCode   false   
    myChildErrorMessage null    
    myErrorCode SVNErrorCode  (id=614)  
    myMessage   "Credentials rejected by SSH server." (id=613)  
    myObjects   Object[0]  (id=616) 
    myThrowable null    
    myType  0   

The URL, username and password are all correct, but as you can see myPrivateKeyFile is null.

I've tried setting the private key path with MAVEN_OPTS='-Dsvnkit.ssh2.key=/home/acme/.ssh/id_rsa' as per SVNKit documentation, but it has no effect.

If run this on another working copy checked-out over https the analysis works fine, further confirming it's a problem with ssh authentication.

Jakub Bochenski
  • 3,113
  • 4
  • 33
  • 61

1 Answers1

3

This is indeed a missing feature. I have created the following ticket: https://jira.sonarsource.com/browse/SONARSCSVN-9

Would you mind testing this updated version of the plugin: https://github.com/SonarSource/sonar-scm-svn/releases/download/1.3-rc1/sonar-scm-svn-plugin-1.3-SNAPSHOT.jar

You should be able to pass additional parameters (or set them in the UI):

-Dsonar.svn.privateKeyPath=<path to private key>
-Dsonar.svn.passphrase.secure=<optional passphrase>

Report any sucess/issue directly in the pull request to not pollute SO: https://github.com/SonarSource/sonar-scm-svn/pull/4

  • Why do you mean "not pollute SO"? Also why is it that sonar staff never upvotes questions about their product? – Jakub Bochenski Feb 22 '16 at 12:38
  • I'm sorry but I'm a very minimal StackOverflow user. By "not pollute SO" I meant that we were previously blamed to use SO as a "chat". To avoid that I was proposing to continue discussion about possible fix for this issue in the pull request that is more suited for conversation. Regarding upvotes I can only talk for myself: I usually upvote a question when I face the same issue as a user. If you mean we should encourage good questions about SQ by upvoting them then you are probably right (again I'm not SO expert). Anyway here is my +1 ;) – Julien H. - SonarSource Team Feb 22 '16 at 13:13
  • Yes, voting is crucial for search positioning and this is my first upvote on a sonar question ever, even though I've filed a few already https://stackoverflow.com/search?q=user:1237617+[sonarqube] – Jakub Bochenski Feb 22 '16 at 17:51
  • @Alex I can confirm the fix is working for me.. Are you sure you are using proper credentials? E.g. why would you use a user called "sonar" on Jenkins? Please note the `sonar.svn.username` given has to be the `ssh` user used in the tunnel not a `svn` commiter -- this tripped me up at first – Jakub Bochenski Mar 11 '16 at 14:35
  • @JakubBochenski Sorry, I deleted my comment in the meantime (because of plea not to "pollute" SO. Yep, I'm sure it's the right credentials - I know naming is not the best :D I'll ask my question on github as suggested. – Alex Mar 11 '16 at 14:47