ci(jenkins): avoid brittle agent nodes
This commit is contained in:
parent
c923be8ff1
commit
2464c61339
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -19,7 +19,9 @@ spec:
|
||||
- key: kubernetes.io/hostname
|
||||
operator: NotIn
|
||||
values:
|
||||
- titan-04
|
||||
- titan-06
|
||||
- titan-11
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: 100
|
||||
preference:
|
||||
|
||||
@ -18,7 +18,9 @@ spec:
|
||||
- key: kubernetes.io/hostname
|
||||
operator: NotIn
|
||||
values:
|
||||
- titan-04
|
||||
- titan-06
|
||||
- titan-11
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: 100
|
||||
preference:
|
||||
|
||||
@ -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}" <<EOF
|
||||
{
|
||||
"status": "ERROR",
|
||||
"error": "sonarqube response missing projectStatus.status"
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
scan_root=build/data-prepper-supply-chain-scan
|
||||
@ -333,7 +368,7 @@ EOF
|
||||
}
|
||||
|
||||
if enabled "${QUALITY_GATE_SONARQUBE_ENFORCE:-1}"; then
|
||||
sonar_status="$(jq -r '.status // .projectStatus.status // .qualityGate.status // empty' build/sonarqube-quality-gate.json 2>/dev/null | tr '[:upper:]' '[:lower:]')"
|
||||
sonar_status="$( (jq -r '.projectStatus.status // .status // .qualityGate.status // empty' build/sonarqube-quality-gate.json 2>/dev/null || true) | tr '[:upper:]' '[:lower:]')"
|
||||
[ -n "${sonar_status}" ] || sonar_status="missing"
|
||||
case "${sonar_status}" in
|
||||
ok|pass|passed|success) ;;
|
||||
@ -453,7 +488,7 @@ EOF
|
||||
fi
|
||||
sonarqube_check="not_applicable"
|
||||
if [ -f build/sonarqube-quality-gate.json ]; then
|
||||
sonar_status="$(jq -r '.status // .projectStatus.status // .qualityGate.status // empty' build/sonarqube-quality-gate.json 2>/dev/null | tr '[:upper:]' '[:lower:]')"
|
||||
sonar_status="$( (jq -r '.projectStatus.status // .status // .qualityGate.status // empty' build/sonarqube-quality-gate.json 2>/dev/null || true) | tr '[:upper:]' '[:lower:]')"
|
||||
if [ -n "${sonar_status}" ]; then
|
||||
case "${sonar_status}" in
|
||||
ok|pass|passed|success) sonarqube_check="ok" ;;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user