From 2464c613399c5a7312664471140b030555437ced Mon Sep 17 00:00:00 2001 From: jenkins Date: Tue, 19 May 2026 18:26:51 -0300 Subject: [PATCH] ci(jenkins): avoid brittle agent nodes --- Jenkinsfile | 2 ++ ci/Jenkinsfile.titan-iac | 2 ++ services/logging/Jenkinsfile.data-prepper | 39 +++++++++++++++++++++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3c69062e..49dec6be 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,7 +19,9 @@ spec: - key: kubernetes.io/hostname operator: NotIn values: + - titan-04 - titan-06 + - titan-11 preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 preference: diff --git a/ci/Jenkinsfile.titan-iac b/ci/Jenkinsfile.titan-iac index 89b8d93b..f0470230 100644 --- a/ci/Jenkinsfile.titan-iac +++ b/ci/Jenkinsfile.titan-iac @@ -18,7 +18,9 @@ spec: - key: kubernetes.io/hostname operator: NotIn values: + - titan-04 - titan-06 + - titan-11 preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 preference: diff --git a/services/logging/Jenkinsfile.data-prepper b/services/logging/Jenkinsfile.data-prepper index a6361b76..116a80bb 100644 --- a/services/logging/Jenkinsfile.data-prepper +++ b/services/logging/Jenkinsfile.data-prepper @@ -23,7 +23,14 @@ spec: - key: kubernetes.io/hostname operator: NotIn values: + - titan-04 - titan-06 + - titan-11 + - titan-13 + - titan-15 + - titan-17 + - titan-18 + - titan-19 preferredDuringSchedulingIgnoredDuringExecution: - weight: 80 preference: @@ -125,6 +132,25 @@ spec: sonar_report="${QUALITY_GATE_SONARQUBE_REPORT:-build/sonarqube-quality-gate.json}" host="${SONARQUBE_HOST_URL%/}" query="$(printf '%s' "${SONARQUBE_PROJECT_KEY}" | sed 's/ /%20/g')" + if [ -s .scannerwork/report-task.txt ]; then + task_id="$(awk -F= '$1 == "ceTaskId" {print $2}' .scannerwork/report-task.txt | head -1)" + if [ -n "${task_id}" ]; then + deadline=$((SECONDS + 180)) + while [ "${SECONDS}" -lt "${deadline}" ]; do + if [ -n "${SONARQUBE_TOKEN:-}" ]; then + auth="$(printf '%s:' "${SONARQUBE_TOKEN}" | base64 | tr -d '\\n')" + ce_payload="$(curl -fsS -H "Authorization: Basic ${auth}" "${host}/api/ce/task?id=${task_id}" 2>/dev/null || true)" + else + ce_payload="$(curl -fsS "${host}/api/ce/task?id=${task_id}" 2>/dev/null || true)" + fi + ce_status="$(printf '%s' "${ce_payload}" | jq -r '.task.status // empty' 2>/dev/null || true)" + case "${ce_status}" in + SUCCESS|FAILED|CANCELED) break ;; + esac + sleep 3 + done + fi + fi sonar_ok=0 if [ -n "${SONARQUBE_TOKEN:-}" ]; then auth="$(printf '%s:' "${SONARQUBE_TOKEN}" | base64 | tr -d '\\n')" @@ -144,6 +170,15 @@ spec: "status": "ERROR", "error": "sonarqube query failed" } +EOF + fi + sonar_status="$(jq -r '.projectStatus.status // .status // .qualityGate.status // empty' "${sonar_report}" 2>/dev/null || true)" + if [ -z "${sonar_status}" ]; then + cat > "${sonar_report}" <