Gradle spring boot code analysis using SonarQube via Jenkins throws error.
I have at the root of the Gradle spring boot project my sonar-project.properties file with the following details
sonar.projectKey=some-project-key
sonar.projectName=some-project-name
sonar.projectVersion=1.0
sonar.sources=src/main/java/
sonar.exclusions=./src/main/resources/**
sonar.language=java
sonar.java.sources=1.8
sonar.java.binaries=build/classes/java/main
In Jenkins under "Global Tool Configuration" SonarQube Scanner is configured as
Name: SonarScanner Install Automatically is checked Install from Maven Central: SonarQube Scanner 3.0.3.778
In the Jenkinsfile the stage is defined as
stage('SonarQube') {
environment {
scannerHome = tool 'SonarScanner'
}
steps {
withSonarQubeEnv('sonarqube') {
sh "${scannerHome}/bin/sonar-scanner"
}
timeout(time: 10, unit: 'MINUTES') {
waitForQualityGate abortPipeline: true
}
}
}
When the job is run I get the following error
INFO: JavaClasspath initialization ERROR: Invalid value for sonar.java.binaries INFO: ------------------------------------------------------------------------ INFO: EXECUTION FAILURE INFO: ------------------------------------------------------------------------ INFO: Total time: 5.890s INFO: Final Memory: 48M/120M INFO: ------------------------------------------------------------------------ ERROR: Error during SonarQube Scanner execution java.lang.IllegalStateException: No files nor directories matching 'build/classes/java/main/**'
Apparently sonar.java.binaries property is causing the problem.
I have experimented with following values one by one for sonar.java.binaries property. Nothing works and every time I get the same error.
build//classes//java//main
build/classes/java/main
build/classes
*//build//classes//java//main//**
//build//classes//java//main//**
build//classes//java//main//**
build/classes/java/main/**
I am at my wit's end. I would appreciate if somebody can help me out.
build/classes
directory? – agabrys