Skip to content

Commit 0c4e769

Browse files
committed
ci: fix issue with sonarqube not getting issues from sonarcloud
1 parent 41adcac commit 0c4e769

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

vars/runJenkinsPipeline.groovy

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,20 @@ def run_pylint(){
4444

4545
def get_sonarqube_unresolved_issues(report_task_file){
4646
script{
47-
48-
def props = readProperties file: '.scannerwork/report-task.txt'
49-
def response = httpRequest url : props['serverUrl'] + "/api/issues/search?componentKeys=" + props['projectKey'] + "&resolved=no"
47+
if(! fileExists(report_task_file)){
48+
error "Could not find ${report_task_file}"
49+
}
50+
def props = readProperties file: report_task_file
51+
if(! props['serverUrl'] || ! props['projectKey']){
52+
error "Could not find serverUrl or projectKey in ${report_task_file}"
53+
}
54+
def response = httpRequest url : props['serverUrl'] + '/api/issues/search?componentKeys=' + props['projectKey'] + '&resolved=no'
5055
def outstandingIssues = readJSON text: response.content
5156
return outstandingIssues
5257
}
5358
}
5459

60+
5561
def installMSVCRuntime(cacheLocation){
5662
def cachedFile = "${cacheLocation}\\vc_redist.x64.exe".replaceAll(/\\\\+/, '\\\\')
5763
withEnv(
@@ -413,8 +419,7 @@ def call(){
413419
unstable "SonarQube quality gate: ${sonarqube_result.status}"
414420
}
415421
if(env.BRANCH_IS_PRIMARY){
416-
def outstandingIssues = get_sonarqube_unresolved_issues('.scannerwork/report-task.txt')
417-
writeJSON file: 'reports/sonar-report.json', json: outstandingIssues
422+
writeJSON(file: 'reports/sonar-report.json', json: get_sonarqube_unresolved_issues('.sonar/report-task.txt'))
418423
recordIssues(tools: [sonarQube(pattern: 'reports/sonar-report.json')])
419424
}
420425
}

0 commit comments

Comments
 (0)