1

I have installed SonarQube 4.2 -
it is running against Oracle XE am running Jenkins on Tomcat 6.x

I have sonar configured with Jenkins ( NOT Sonar runner )

am trying to run a Jenkins job and then invoke Sonar through : "Invoke top level maven targets"

Here I am invoking the command:

-e clean install sonar:sonar -Dsonar.dynamicAnalysis=reuseReports -Dsonar.projectVersion=ABC-${BUILD_NUMBER} -Dsonar.forceAnalysis=true

The issue is that the job fails with the following exception:

INFO: SonarQube Server 4.2

[INFO] [16:10:29.258] Load batch settings

[INFO] [16:10:30.038] User cache: C:\Users\xyz\.sonar\cache
[INFO] [16:10:30.053] Install plugins
[INFO] [16:10:30.381] Install JDBC driver
[WARN] [16:10:30.381] H2 database should be used for evaluation purpose only
[INFO] [16:10:30.381] Create JDBC datasource for jdbc:h2:tcp://localhost/sonar

[ERROR] Fail to connect to database
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Fail to connect to database

Connection refused: connect
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Fail to connect to database

I have checked sonar.properties and it is configured to work with OracleXE

My project that is executed has the following entry in its pom ( maven2 ) <plugin> <groupId>org.codehaus.sonar</groupId> <artifactId>sonar-maven-plugin</artifactId> <version>4.2</version> </plugin>

Thanks

akila
  • 667
  • 2
  • 7
  • 21

1 Answers1

1

You need to configure maven to actually use the correct database when you use the maven goal. This is done in your settings.xml file.

Please refer to the documentation for how to configure it: http://docs.codehaus.org/display/SONAR/Installing+and+Configuring+Maven

benzonico
  • 10,635
  • 5
  • 42
  • 50
  • Thanks @benzonico - but I do not think that this is needed if I am invoking maven through jenkins and in jenkins I am configuring sonar credentials including database details - and I am positive I have had it work this way some months back without having the need to configure database in settings.xml – akila May 28 '14 at 13:49
  • got it to work-the link on so helped : [link]http://stackoverflow.com/questions/13472283/do-i-need-sonar-and-sonar-runner-for-jenkins I did not have sonar runner installed - was confused Jenkins was providing sonar-runner and sonar - so for those who are confused - visit the link - has the details My problem was idiotic - I was trying to run sonar through **Post Steps Invoke Top level Maven targets** and when I changed it to **Post-build actions Sonar' it worked for me - hope that this is useful to others and yes you do not need to configure database in settings.xml in this case – akila May 29 '14 at 06:58