ci: stop overwriting published quality metrics in post
This commit is contained in:
parent
9faabcbc0e
commit
a0b3da34ce
90
Jenkinsfile
vendored
90
Jenkinsfile
vendored
@ -203,96 +203,6 @@ python -c "import json; payload=json.load(open('build/coverage.json', encoding='
|
|||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
success {
|
|
||||||
container('tester') {
|
|
||||||
sh '''
|
|
||||||
set -euo pipefail
|
|
||||||
export QUALITY_STATUS=ok
|
|
||||||
python - <<'PY'
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import urllib.request
|
|
||||||
|
|
||||||
suite = os.environ.get("SUITE_NAME", "ariadne")
|
|
||||||
status = os.environ.get("QUALITY_STATUS", "failed")
|
|
||||||
gateway = os.environ.get("PUSHGATEWAY_URL", "http://platform-quality-gateway.monitoring.svc.cluster.local:9091").rstrip("/")
|
|
||||||
text = urllib.request.urlopen(f"{gateway}/metrics", timeout=10).read().decode("utf-8", errors="replace")
|
|
||||||
|
|
||||||
def counter(name: str) -> float:
|
|
||||||
pattern = re.compile(
|
|
||||||
rf'^platform_quality_gate_runs_total\\{{[^}}]*job="platform-quality-ci"[^}}]*suite="{re.escape(suite)}"[^}}]*status="{name}"[^}}]*\\}}\\s+([0-9]+(?:\\.[0-9]+)?)$',
|
|
||||||
re.M,
|
|
||||||
)
|
|
||||||
match = pattern.search(text)
|
|
||||||
return float(match.group(1)) if match else 0.0
|
|
||||||
|
|
||||||
ok = counter("ok")
|
|
||||||
failed = counter("failed")
|
|
||||||
if status == "ok":
|
|
||||||
ok += 1
|
|
||||||
else:
|
|
||||||
failed += 1
|
|
||||||
payload = (
|
|
||||||
"# TYPE platform_quality_gate_runs_total counter\\n"
|
|
||||||
f'platform_quality_gate_runs_total{{suite="{suite}",status="ok"}} {int(ok)}\\n'
|
|
||||||
f'platform_quality_gate_runs_total{{suite="{suite}",status="failed"}} {int(failed)}\\n'
|
|
||||||
)
|
|
||||||
req = urllib.request.Request(
|
|
||||||
f"{gateway}/metrics/job/platform-quality-ci/suite/{suite}",
|
|
||||||
data=payload.encode("utf-8"),
|
|
||||||
method="POST",
|
|
||||||
headers={"Content-Type": "text/plain"},
|
|
||||||
)
|
|
||||||
urllib.request.urlopen(req, timeout=10).read()
|
|
||||||
PY
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
failure {
|
|
||||||
container('tester') {
|
|
||||||
sh '''
|
|
||||||
set -euo pipefail
|
|
||||||
export QUALITY_STATUS=failed
|
|
||||||
python - <<'PY'
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import urllib.request
|
|
||||||
|
|
||||||
suite = os.environ.get("SUITE_NAME", "ariadne")
|
|
||||||
status = os.environ.get("QUALITY_STATUS", "failed")
|
|
||||||
gateway = os.environ.get("PUSHGATEWAY_URL", "http://platform-quality-gateway.monitoring.svc.cluster.local:9091").rstrip("/")
|
|
||||||
text = urllib.request.urlopen(f"{gateway}/metrics", timeout=10).read().decode("utf-8", errors="replace")
|
|
||||||
|
|
||||||
def counter(name: str) -> float:
|
|
||||||
pattern = re.compile(
|
|
||||||
rf'^platform_quality_gate_runs_total\\{{[^}}]*job="platform-quality-ci"[^}}]*suite="{re.escape(suite)}"[^}}]*status="{name}"[^}}]*\\}}\\s+([0-9]+(?:\\.[0-9]+)?)$',
|
|
||||||
re.M,
|
|
||||||
)
|
|
||||||
match = pattern.search(text)
|
|
||||||
return float(match.group(1)) if match else 0.0
|
|
||||||
|
|
||||||
ok = counter("ok")
|
|
||||||
failed = counter("failed")
|
|
||||||
if status == "ok":
|
|
||||||
ok += 1
|
|
||||||
else:
|
|
||||||
failed += 1
|
|
||||||
payload = (
|
|
||||||
"# TYPE platform_quality_gate_runs_total counter\\n"
|
|
||||||
f'platform_quality_gate_runs_total{{suite="{suite}",status="ok"}} {int(ok)}\\n'
|
|
||||||
f'platform_quality_gate_runs_total{{suite="{suite}",status="failed"}} {int(failed)}\\n'
|
|
||||||
)
|
|
||||||
req = urllib.request.Request(
|
|
||||||
f"{gateway}/metrics/job/platform-quality-ci/suite/{suite}",
|
|
||||||
data=payload.encode("utf-8"),
|
|
||||||
method="POST",
|
|
||||||
headers={"Content-Type": "text/plain"},
|
|
||||||
)
|
|
||||||
urllib.request.urlopen(req, timeout=10).read()
|
|
||||||
PY
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
if (fileExists('build/junit.xml')) {
|
if (fileExists('build/junit.xml')) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user