From 82780651f7d563f7720582716b695c5e3a1ed8eb Mon Sep 17 00:00:00 2001 From: codex Date: Wed, 20 May 2026 02:31:01 -0300 Subject: [PATCH] ci(ariadne): wait for refreshed sonar gate --- Jenkinsfile | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f85c228..651d0cc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -246,6 +246,7 @@ project_key = os.getenv('SONARQUBE_PROJECT_KEY', '').strip() token = os.getenv('SONARQUBE_TOKEN', '').strip() report_path = os.getenv('QUALITY_GATE_SONARQUBE_REPORT', 'build/sonarqube-quality-gate.json') payload = {"status": "ERROR", "note": "missing SONARQUBE_HOST_URL and/or SONARQUBE_PROJECT_KEY"} +analysis_id = "" if host and project_key: query = urllib.parse.urlencode({"projectKey": project_key}) request = urllib.request.Request(f"{host}/api/qualitygates/project_status?{query}", method="GET") @@ -436,7 +437,17 @@ def request_json(url: str) -> dict: if host and project_key: - task_path = os.path.join('build', '.scannerwork', 'report-task.txt') + task_path = next( + ( + candidate + for candidate in ( + os.path.join('.scannerwork', 'report-task.txt'), + os.path.join('build', '.scannerwork', 'report-task.txt'), + ) + if os.path.exists(candidate) + ), + "", + ) if os.path.exists(task_path): ce_task_id = "" with open(task_path, encoding="utf-8") as handle: @@ -449,10 +460,13 @@ if host and project_key: break query = urllib.parse.urlencode({"id": ce_task_id}) task = request_json(f"{host}/api/ce/task?{query}").get("task", {}) - if task.get("status") in {"SUCCESS", "FAILED", "CANCELED"}: + if task.get("status") == "SUCCESS": + analysis_id = str(task.get("analysisId") or "") + break + if task.get("status") in {"FAILED", "CANCELED"}: break time.sleep(2) - query = urllib.parse.urlencode({"projectKey": project_key}) + query = urllib.parse.urlencode({"analysisId": analysis_id} if analysis_id else {"projectKey": project_key}) try: payload = request_json(f"{host}/api/qualitygates/project_status?{query}") except Exception as exc: # noqa: BLE001