Failed to execute Scanner Maven: 'Please provide compiled classes' error

java
maven

(naourouz) #1

Hi,
-Jenkins 2.89.4
-Maven:3.5.4
-java-8 version
-SonarQube Scanner 3.2.0 (plugin installed in Jenkins)
Gitlab

I’m tring to configure Jenkins jobs to run analysis (Maven project)
-I’ve created a free style project that contains steps and post-build action
To configure Jenkins job,

  • Build Environment, I checked “Prepare SonarQube Scanner environment”
    -For the build, i choosed invoke top-level Maven target:
    Maven Version default
    Goals: $SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL
    POM: path/pom.xlm

But, when i build my project, i have the following message:

I would like to ask if i add a plugin to pom.xml (Maven), witch version should i use?
thank you in advance


(G Ann Campbell) #2

Hi,

First, the post-build step has long since been deprecated. Plus, it doesn’t use the environment variables that are exposed when you turn on ‘Prepare SonarQube Scanner environment’. Instead, you should be using a normal Maven step at the end of your build, as documented.

All that said, this should work anyway if you actually build your project first. But the error message indicates that you don’t:

Please provide compiled classes of your project with sonar.java.binaries property

Ann


(naourouz) #3

Hi Ann,
Thank you for your reply
I need please more clarifications
I followed the document that you gave me
what I understood by “provide compiled classes of your project with sonar.java.binaries property”
I added in my porm.xml this plugin:

org.codehaus.mojo sonar-maven-plugin 3.4.1.1168

in the settings.xml for my maven configurations (i’m going to C:\apache-maven-3.5.4\conf\setting.xml) with this content

<settings>
    <pluginGroups>
        <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
    </pluginGroups>
    <profiles>
        <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <!-- Optional URL to server. Default value is http://localhost:9000 -->
                <sonar.host.url>
                  http://myserver:9000
                </sonar.host.url>
            </properties>
        </profile>
     </profiles>
</settings>

I want to know if I’m on the right way.


(G Ann Campbell) #4

Hi,

You don’t need to do anything to your pom. You just need to make sure you compile before you analyze. Once you do, Maven will automatically know where your binaries are, and the SonarQube Scanner for Maven (invoked by the Maven build step you’re going to add at the end of your build with a command of sonar:sonar) will naturally know where to look.

Ann