Getting Error while trying to connect SonarQube to Jenkins

I am trying to connect SonarQube to Jenkins.I have installed SonarQube plugin and I have set up the SonarQube server in “Configure system” of jenkins. I have done sonarscanner installation in “Global tool configuration” of jenkins. I am giving below code in pipeline:

node {
stage(‘SCM’) {
git ‘path to git’
}
stage(‘SonarQube analysis’) {
def mvnHome = tool name: ‘M3’, type : ‘maven’
withSonarQubeEnv(credentialsId: ‘admin’) {
// some block
// If you have configured more than one global server connection, you can specify its name
‘sh ${mvnHome}/bin/mvn clean package sonar:sonar’
}
}
}

I am getting warning WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succeed? and there is no report generated in sonarqube about the code smells. Can anyone help

Hi,

Welcome to the the community!

Could you provide your code-formatted (``` on the line before and on the line after) Jenkins job log?

 
Ann

Thanks Ann. Not sure what you are asking. Please find my code below:
node {
stage(‘SCM’) {
git ‘https://github.com/rkadiyali/jpmc.git
}
stage(‘SonarQube analysis’) {
def mvnHome = tool name: ‘M3’, type : ‘maven’
withSonarQubeEnv(credentialsId: ‘admin’) {
‘sh ${mvnHome}/bin/mvn sonar:sonar’
}
}
}
I want to pull code commited in github to jenkins and run sonarqube analaysis on it. Can you please help?

Hi,

I’m asking for the contents of the Jenkins console output.

 
Ann

Please find jenkins console output:
Running in Durability level: MAX_SURVIVABILITY [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\demo-sonarqube [Pipeline] { [Pipeline] stage [Pipeline] { (SCM) [Pipeline] git The recommended git tool is: NONE No credentials specified > C:\Program Files\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > C:\Program Files\Git\bin\git.exe config remote.origin.url https://github.com/rkadiyali/jpmc.git # timeout=10 Fetching upstream changes from https://github.com/rkadiyali/jpmc.git > C:\Program Files\Git\bin\git.exe --version # timeout=10 > git --version # ‘git version 2.28.0.windows.1’ > C:\Program Files\Git\bin\git.exe fetch --tags --force --progress – https://github.com/rkadiyali/jpmc.git +refs/heads/:refs/remotes/origin/ # timeout=10 > C:\Program Files\Git\bin\git.exe rev-parse “refs/remotes/origin/master^{commit}” # timeout=10 > C:\Program Files\Git\bin\git.exe rev-parse “refs/remotes/origin/origin/master^{commit}” # timeout=10 Checking out Revision 2fe4542aacfbb43031e40e7c7c37642c6fed8e97 (refs/remotes/origin/master) > C:\Program Files\Git\bin\git.exe config core.sparsecheckout # timeout=10 > C:\Program Files\Git\bin\git.exe checkout -f 2fe4542aacfbb43031e40e7c7c37642c6fed8e97 # timeout=10 > C:\Program Files\Git\bin\git.exe branch -a -v --no-abbrev # timeout=10 > C:\Program Files\Git\bin\git.exe branch -D master # timeout=10 > C:\Program Files\Git\bin\git.exe checkout -b master 2fe4542aacfbb43031e40e7c7c37642c6fed8e97 # timeout=10 Commit message: “Update testing” > C:\Program Files\Git\bin\git.exe rev-list --no-walk 2fe4542aacfbb43031e40e7c7c37642c6fed8e97 # timeout=10 [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (SonarQube analysis) [Pipeline] tool [Pipeline] withSonarQubeEnv Injecting SonarQube environment variables using the configuration: SonarQube [Pipeline] { [Pipeline] } WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succeed? [Pipeline] // withSonarQubeEnv [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS

Hi,

Your script includes a Maven analysis, but I don’t see that analysis command reflected in the logging you’ve provided. I don’t know where to tell you to look for that logging, but we’re not going to get very far without it.

 
Ann

The log I have provided is from console output.