Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
fix(ci): manage sonar quality gate timeout (#628)
Browse files Browse the repository at this point in the history
zguennoune02 committed Jul 8, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent d8a648d commit 07538bd
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -86,31 +86,10 @@ try {
// sonarQube step to get qualityGate result
stage('Quality gate') {
node {
def reportFilePath = "target/sonar/report-task.txt"
def reportTaskFileExists = fileExists "${reportFilePath}"
if (reportTaskFileExists) {
echo "Found report task file"
def taskProps = readProperties file: "${reportFilePath}"
echo "taskId[${taskProps['ceTaskId']}]"
timeout(time: 10, unit: 'MINUTES') {
while (true) {
sleep 5
def taskStatusResult =
sh(returnStdout: true, script: "curl -s -X GET -u ${authString} \'${sonarProps['sonar.host.url']}/api/ce/task?id=${taskProps['ceTaskId']}\'")
echo "taskStatusResult[${taskStatusResult}]"
def taskStatus = new JsonSlurper().parseText(taskStatusResult).task.status
echo "taskStatus[${taskStatus}]"
// Status can be SUCCESS, ERROR, PENDING, or IN_PROGRESS. The last two indicate it's
// not done yet.
if (taskStatus != "IN_PROGRESS" && taskStatus != "PENDING") {
break;
}
def qualityGate = waitForQualityGate()
if (qualityGate.status != 'OK') {
currentBuild.result = 'FAIL'
}
}
}
sleep 120
def qualityGate = waitForQualityGate()
if (qualityGate.status != 'OK') {
currentBuild.result = 'FAIL'
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Quality gate failure: ${qualityGate.status}.');

0 comments on commit 07538bd

Please sign in to comment.