ci: keep quality report handling in its own script
All checks were successful
Tests / Declarative: Post Actions passed: 155
All checks were successful
Tests / Declarative: Post Actions passed: 155
This commit is contained in:
parent
ef9e79737c
commit
5fbc6d0d5c
48
Jenkinsfile
vendored
48
Jenkinsfile
vendored
@ -320,52 +320,8 @@ EOF
|
|||||||
stage('Run quality gate') {
|
stage('Run quality gate') {
|
||||||
steps {
|
steps {
|
||||||
container('publisher') {
|
container('publisher') {
|
||||||
sh '''
|
sh 'sh scripts/report_quality_gate.sh'
|
||||||
set -eu
|
|
||||||
mkdir -p build
|
|
||||||
set +e
|
|
||||||
apt-get update
|
|
||||||
apt_rc=$?
|
|
||||||
if [ "${apt_rc}" -eq 0 ]; then
|
|
||||||
apt-get install -y --no-install-recommends golang-go nodejs npm
|
|
||||||
apt_rc=$?
|
|
||||||
fi
|
|
||||||
if [ "${apt_rc}" -eq 0 ]; then
|
|
||||||
python -m testing.pegasus_gate report
|
|
||||||
gate_rc=$?
|
|
||||||
else
|
|
||||||
gate_rc="${apt_rc}"
|
|
||||||
fi
|
|
||||||
set -e
|
|
||||||
if [ ! -f build/gate-summary.json ]; then
|
|
||||||
python3 - <<'PY'
|
|
||||||
import json
|
|
||||||
from pathlib import Path
|
|
||||||
Path("build/gate-summary.json").write_text(
|
|
||||||
json.dumps(
|
|
||||||
{
|
|
||||||
"ok": False,
|
|
||||||
"issues": [
|
|
||||||
{
|
|
||||||
"check": "gate_glue",
|
|
||||||
"path": "Jenkinsfile",
|
|
||||||
"detail": "quality gate dependencies or report command failed before summary generation",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"file_count": 0,
|
|
||||||
"backend_coverage": {},
|
|
||||||
"frontend_coverage": {},
|
|
||||||
},
|
|
||||||
indent=2,
|
|
||||||
sort_keys=True,
|
|
||||||
)
|
|
||||||
+ "\\n",
|
|
||||||
encoding="utf-8",
|
|
||||||
)
|
|
||||||
PY
|
|
||||||
fi
|
|
||||||
printf '%s\n' "${gate_rc}" > build/quality-report.rc
|
|
||||||
'''
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
46
scripts/report_quality_gate.sh
Executable file
46
scripts/report_quality_gate.sh
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generate a gate report, including an explicit failure if tooling cannot start.
|
||||||
|
set -eu
|
||||||
|
mkdir -p build
|
||||||
|
set +e
|
||||||
|
apt-get update
|
||||||
|
apt_rc=$?
|
||||||
|
if [ "${apt_rc}" -eq 0 ]; then
|
||||||
|
apt-get install -y --no-install-recommends golang-go nodejs npm
|
||||||
|
apt_rc=$?
|
||||||
|
fi
|
||||||
|
if [ "${apt_rc}" -eq 0 ]; then
|
||||||
|
python -m testing.pegasus_gate report
|
||||||
|
gate_rc=$?
|
||||||
|
else
|
||||||
|
gate_rc="${apt_rc}"
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
|
if [ ! -f build/gate-summary.json ]; then
|
||||||
|
python3 - <<'PY'
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
Path("build/gate-summary.json").write_text(
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
"ok": False,
|
||||||
|
"issues": [
|
||||||
|
{
|
||||||
|
"check": "gate_glue",
|
||||||
|
"path": "Jenkinsfile",
|
||||||
|
"detail": "quality gate dependencies or report command failed before summary generation",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"file_count": 0,
|
||||||
|
"backend_coverage": {},
|
||||||
|
"frontend_coverage": {},
|
||||||
|
},
|
||||||
|
indent=2,
|
||||||
|
sort_keys=True,
|
||||||
|
)
|
||||||
|
+ "\n",
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
PY
|
||||||
|
fi
|
||||||
|
printf '%s\n' "${gate_rc}" > build/quality-report.rc
|
||||||
Loading…
x
Reference in New Issue
Block a user