We are using Sonarqube community edition 9.9.1, and it’s deployed through docker container.
I’m currently facing an issue with sending out the SonarQube analysis report via email from a Jenkins job. Despite successfully completing the analysis, the email attachment contains Jenkins build logs instead of the SonarQube report.
The report is displayed on the sonarqube dashboard.
The stage block in jenskinsfile is as below, check out he post block.
stage('sonarqube-analysis') {
steps {
dir("${SOURCE_PATH}") {
script {
def scannerHome = tool 'SonarScanner for MSBuild 5.13'
echo "${scannerHome}"
echo "JAVA_HOME - ${env.JAVA_HOME}"
env.SCANNERHOME = scannerHome
echo "${env.SCANNERHOME}"
echo "${SCANNERHOME}"
withSonarQubeEnv('Sonarqube') {
try {
bat label: 'msbuild', script: '''
dotnet %SCANNERHOME%\\SonarScanner.MSBuild.dll begin /k:\"Test\" /d:sonar.verbose=true
msbuild.exe eBankit.CCS.sln /nologo /nr:false /m /nologo /verbosity:minimal /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:PublishBaseUrl="%OUTPUT_PATH%" /p:platform="Any CPU" /p:configuration="Release" /p:WarningLevel=0 /p:RestorePackages=false /p:DebugType=None /p:VisualStudioVersion="16.0"
dotnet %SCANNERHOME%\\SonarScanner.MSBuild.dll end
'''
} catch (err) {
currentBuild.result = 'FAILURE'
error(err.getMessage())
}
}
}
}
}
post {
always {
// Send email with SonarQube analysis report
emailext body: 'SonarQube analysis report is attached.',
subject: 'SonarQube Analysis Report',
to: 'junaid.mohammed@example.com',
attachLog: true,
attachmentsPattern: '**/target/sonar/report-task.txt'
}
}
}
How can i get the reports to send rather than the build logs