Hello Team,
I am on Enterprise EditionVersion 7.4 (build 18908)
I am using Jenkins v2.134 with sonarqube plugin v2.6.1
I am using Jenkins scripted pipeline and I am doing the analysis with gradle.
def gradleArgs = [
"-Dsonar.projectName=${projectName}-jenkins",
"-Dsonar.projectKey=${projectName}-jenkins",
"-Dsonar.login=${SVC_TOKEN}",
"-PsonarBranch=${sonarBranch}",
'-Dsonar.analysis.mode=publish']
def gradleCommand = "gradle --info sonarqube ${gradleArgs.join(' ')}"
withSonarQubeEnv(‘my-sonar') {
sh gradleCommand
}
}
And this is how I check my quality analysis results
timeout(time: 30, unit: ‘MINUTES’) {
// Just in case something goes wrong, pipeline will be killed after a timeout
def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
if (qg.status != ‘OK’) {
error “Pipeline aborted due to sonar quality gate failure: ${qg.status}”
}
}
Everything works as expected in terms of analysis.
However if I browse the Jenkins page for that job, I get the below exception in my Jenkins logs.
Apr 30, 2019 11:14:42 AM hudson.plugins.sonar.client.SQProjectResolver resolve
WARNING: Error fetching project information
org.sonarqube.ws.client.HttpException: Error 400 on https://sonarqube_URL/api/qualitygates/project_status?projectKey=
at org.sonarqube.ws.client.BaseResponse.failIfNotSuccessful(BaseResponse.java:34)
at hudson.plugins.sonar.client.HttpClient.getHttp(HttpClient.java:36)
at hudson.plugins.sonar.client.WsClient.getQualityGate54(WsClient.java:100)
at hudson.plugins.sonar.client.SQProjectResolver.getQualityGate(SQProjectResolver.java:104)
at hudson.plugins.sonar.client.SQProjectResolver.resolve(SQProjectResolver.java:66)
at hudson.plugins.sonar.action.SonarCacheAction.get(SonarCacheAction.java:79)
at hudson.plugins.sonar.action.SonarCacheAction.get(SonarCacheAction.java:52)
at hudson.plugins.sonar.action.SonarProjectActionFactory.createProjectPage(SonarProjectActionFactory.java:117)
I understand that, it make those queries to display the SonarQube widget on the job page. Since the analysis is asynchronous, you have to poll for the results until they are fetched. Queries should reuse the authentication you have configured in the Jenkins global settings.
But in my case the error is 400 as we can see it is missing the projectKey.
From where does this API picks up the “projectKey” as that seems to be going as empty.
Can someone please suggest what I am missing here?