I have intergrated Sonarqube in Jenkins Pipeline, it working as below define:
stage('static check') {
steps {
echo "starting codeAnalyze with SonarQube......"
//sonar:sonar.QualityGate should pass
withSonarQubeEnv('sonar') {
sh "mvn -f pom.xml clean compile sonar:sonar -U"
}
script {
timeout(10) {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
echo "failure: ${qg.status}"
# Plan to send notify to Slack, But can NOT to obtain the Sonar report URL or TaskId
}
}
}
}
}
Plan to send corresponding notify to Slack, But can NOT to obtain the Sonar report URL or TaskId
And found some guys suggest that use BUILD_LOG_REGEX: SonarQube result URL: ${BUILD_LOG_REGEX, regex=".*ANALYSIS SUCCESSFUL, you can browse (.*)", showTruncatedLines=false, substText="$1"}
, but this only working in Email Extension Plugin.
Another suggest is compose the report URL by this: ProjectURL = host + "/dashboard?id=" + ProjectID
, and we not easy to get the ProjectID, since the projectID is compose from Pom.xml as: groupId:artifactId
.
Maybe there is some easy way to get the Sonar TaskId or Report URL, Especially whether there is the waitForQualityGate() or other method
will return the Sonar TaskId or Report URL ?
question from:
https://stackoverflow.com/questions/65880598/how-to-obtain-the-sonarqube-taskid-report-url-in-jenkins-pipeline 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…