ci(ariadne): wait for refreshed sonar gate

This commit is contained in:
codex 2026-05-20 02:31:01 -03:00
parent 38327e36e6
commit 82780651f7

20
Jenkinsfile vendored
View File

@ -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