Integrate SonarQube with Jenkins pipeline

System Environment

  • Installed the SonarQube 7.4 in my winodows and installed the sonar qube scanner plugin with version 2.8.1

Requirement

  • We want to get the static code analysis report(coverage, duplication of codes and code quality) of my project in sonr qube server

Tried so far:

I have added my sonar qube server details in Jenkins configuration.

I have addded the below sonar-project.properties files in my project

sonar.projectKey=Sample
sonar.projectName="ReleaseTest"
sonar.projectversion=1.0

sonar.sources= src
sonar.visualstudio.solution=My.Application.sln

sonar.sourceEncoding=UTF-8
sonar.cobal.copy.directories=/copy
sonar.visualstudio.enable=true

I have added the below stage in jenkins file because I am using pipeline jobs.

stage(‘SonarQube analysis’)
{
// requires SonarQube Scanner 2.8+
def scannerHome = tool ‘SonarQube Scanner 2.8’;
withSonarQubeEnv(‘My SonarQube Server’) {
bat “${scannerHome}/bin/sonar-scanner”
}
}

I have tried above mutiple projects and faced the below kind of error.

Issue 1

got the empty report

Issue 2:

faced the error which have mentioned in below consolidated issues image

Issue 3:

In some of the project I faced the error sonarproject.key and sonar.sorces was not defined even I defined the sonar.project.key and sonar.sorces in sonar properties file.

Could you please help to achieve my requirement?

The correct file name is sonar-project.properties :slight_smile:

sorry wrongly mentioned in my query.I have already set the properties file name as sonar-project.properties. even though I am facing same issues.