I am working on a project to analyze the code with sonarqube in jenkins. The project structure under workspace is: /var/lib/jenkins/workspace/myproject-trunk-sonar/myproject/pom.xml, Module1, Module2, etc
My sonar-project.properties:
# Required metadata sonar.projectKey=Myproject sonar.projectName=Myproject sonar.projectVersion=1.0 #Set modules IDs sonar.modules=Module1, Module2 # Comma-separated paths to directories with sources (required) sonar.sources=src/main/java # Language sonar.language=java # Encoding of the source files sonar.sourceEncoding=UTF-8 If I have the sonar-project.properties file under /var/lib/jenkins/workspace/myproject-trunk-sonar/myproject where my pom.xml and Modules are, I see the error below:
ERROR: Error during SonarQube Scanner execution ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.sources ERROR: ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging. ERROR: SonarQube scanner exited with non-zero code: 1 If I have the sonar-project.properties file under /var/lib/jenkins/workspace/myproject-trunk-sonar, I see the error below:
ERROR: Error during SonarQube Scanner execution java.lang.IllegalStateException: The base directory of the module 'Module1' does not exist: /var/lib/jenkins/workspace/myproject-trunk-sonar/Module1 at org.sonarsource.scanner.cli.Conf.setModuleBaseDir(Conf.java:180) at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:172) at org.sonarsource.scanner.cli.Conf.loadModulesProperties(Conf.java:137) at org.sonarsource.scanner.cli.Conf.loadProjectProperties(Conf.java:111) at org.sonarsource.scanner.cli.Conf.properties(Conf.java:59) at org.sonarsource.scanner.cli.Main.execute(Main.java:68) at org.sonarsource.scanner.cli.Main.main(Main.java:61) ERROR: ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging. ERROR: SonarQube scanner exited with non-zero code: 1 How can I let the sonar scanner look at the directory where the modules with java code is? When I have the properties file in the directory where the modules are it couldn't even find the properties file and complained about missing mandatory fields.
Thanks for any help.
mvn sonar:sonar(after doing a compile, of course)