Validar estado de Quality Gate para ejecutar acciones en el pipeline NOTA: Solo funciona con Sonar 6.X
sleep 3 //Para darle tiempo a sonar de procesas el QG
timeout(1) { // Just in case something goes wrong, pipeline will be killed after a timeout
def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}