Jenkins 2.138.4
SonarQube scanner 3.3.0.1492
SonarQube server 6.7.5
Trying to gate on SQ results. Using a minimal pipeline, and withSonarQubeEnv, the output file seems to be missing. Subsequent steps fail getting the task id.
Pipeline (some date redacted with *):
stage('build and test') {
node('mesos') {
checkout([$class: 'GitSCM', branches: [[name: '**']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'WipeWorkspace']], submoduleCfg: [], userRemoteConfigs: [[name: 'origin', refspec: '+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*', url: '*']]])
sh "mvn clean test -B -U -T 4 -s ${WORKSPACE}/settings.xml cobertura:cobertura -Dcobertura.report.format=xml -Dmaven.test.failure.ignore=true"
def scannerHome = tool 'Sonar-QA'
withSonarQubeEnv('SonarQA') {
sh """
${scannerHome}/bin/sonar-scanner \
-Dsonar.projectKey=* \
-Dsonar.projectName=* \
-Dsonar.sourceEncoding=UTF-8 \
-Dsonar.java.source=1.8 \
-Dsonar.sources=src/main/java \
-Dsonar.tests=src/test \
-Dsonar.modules=* \
-Dsonar.java.binaries=${WORKSPACE}/*/target/classes \
-Dsonar.analysis.mode=preview \
-Dsonar.github.disableInlineComments=false \
-Dsonar.github.pullRequest=${ghprbPullId} \
-Dsonar.github.repository=* \
-Dsonar.github.oauth=* \
"""
}
timeout(time: 15, unit: 'MINUTES') {
withSonarQubeEnv('SonarQA') {
def gate = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
if (gate.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${gate.status}"
}
echo "gate: ${gate.toString()}"
}
}
}
}
INFO: 888/888 components tracked
INFO: ANALYSIS SUCCESSFUL
INFO: Executing post-job GitHub Pull Request Issue Publisher
INFO: Task total time: 1:36.467 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:42.234s
INFO: Final Memory: 61M/3005M
INFO: ------------------------------------------------------------------------
[Pipeline] }
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?