ci(pegasus): keep Jenkinsfile under LOC gate

This commit is contained in:
codex 2026-05-20 05:49:54 -03:00
parent 1a6397fca6
commit fe83ebca09

19
Jenkinsfile vendored
View File

@ -64,18 +64,15 @@ spec:
disableConcurrentBuilds() disableConcurrentBuilds()
buildDiscarder(logRotator(daysToKeepStr: '30', numToKeepStr: '200', artifactDaysToKeepStr: '30', artifactNumToKeepStr: '120')) buildDiscarder(logRotator(daysToKeepStr: '30', numToKeepStr: '200', artifactDaysToKeepStr: '30', artifactNumToKeepStr: '120'))
} }
triggers { triggers {
pollSCM('H/5 * * * *') pollSCM('H/5 * * * *')
} }
stages { stages {
stage('Checkout') { stage('Checkout') {
steps { steps {
checkout scm checkout scm
} }
} }
stage('Collect SonarQube evidence') { stage('Collect SonarQube evidence') {
steps { steps {
container('quality-tools') { container('quality-tools') {
@ -110,7 +107,6 @@ import json
import os import os
import urllib.parse import urllib.parse
import urllib.request import urllib.request
host = os.getenv('SONARQUBE_HOST_URL', '').strip().rstrip('/') host = os.getenv('SONARQUBE_HOST_URL', '').strip().rstrip('/')
project_key = os.getenv('SONARQUBE_PROJECT_KEY', '').strip() project_key = os.getenv('SONARQUBE_PROJECT_KEY', '').strip()
token = os.getenv('SONARQUBE_TOKEN', '').strip() token = os.getenv('SONARQUBE_TOKEN', '').strip()
@ -135,7 +131,6 @@ PY
} }
} }
} }
stage('Collect Supply Chain evidence') { stage('Collect Supply Chain evidence') {
steps { steps {
container('quality-tools') { container('quality-tools') {
@ -174,7 +169,6 @@ EOF
import json import json
import os import os
from pathlib import Path from pathlib import Path
report_path = Path(os.getenv('QUALITY_GATE_IRONBANK_REPORT', 'build/ironbank-compliance.json')) report_path = Path(os.getenv('QUALITY_GATE_IRONBANK_REPORT', 'build/ironbank-compliance.json'))
if report_path.exists(): if report_path.exists():
raise SystemExit(0) raise SystemExit(0)
@ -192,7 +186,6 @@ PY
} }
} }
} }
stage('Backend unit tests') { stage('Backend unit tests') {
steps { steps {
container('go-tester') { container('go-tester') {
@ -252,7 +245,6 @@ EOF
} }
} }
} }
stage('Frontend unit tests') { stage('Frontend unit tests') {
steps { steps {
container('node-tester') { container('node-tester') {
@ -307,7 +299,6 @@ EOF
} }
} }
} }
stage('Run quality gate') { stage('Run quality gate') {
steps { steps {
container('publisher') { container('publisher') {
@ -332,7 +323,6 @@ EOF
python3 - <<'PY' python3 - <<'PY'
import json import json
from pathlib import Path from pathlib import Path
Path("build/gate-summary.json").write_text( Path("build/gate-summary.json").write_text(
json.dumps( json.dumps(
{ {
@ -361,7 +351,6 @@ PY
} }
} }
} }
stage('Publish test metrics') { stage('Publish test metrics') {
steps { steps {
container('publisher') { container('publisher') {
@ -372,7 +361,6 @@ PY
} }
} }
} }
stage('Enforce quality gate') { stage('Enforce quality gate') {
steps { steps {
container('publisher') { container('publisher') {
@ -389,19 +377,16 @@ PY
echo "quality gate failed with rc=${gate_rc}" >&2 echo "quality gate failed with rc=${gate_rc}" >&2
fail=1 fail=1
fi fi
enabled() { enabled() {
case "$(printf '%s' "${1:-}" | tr '[:upper:]' '[:lower:]')" in case "$(printf '%s' "${1:-}" | tr '[:upper:]' '[:lower:]')" in
1|true|yes|on) return 0 ;; 1|true|yes|on) return 0 ;;
*) return 1 ;; *) return 1 ;;
esac esac
} }
if enabled "${QUALITY_GATE_SONARQUBE_ENFORCE:-1}"; then if enabled "${QUALITY_GATE_SONARQUBE_ENFORCE:-1}"; then
sonar_status="$(python3 - <<'PY' sonar_status="$(python3 - <<'PY'
import json import json
from pathlib import Path from pathlib import Path
path = Path("build/sonarqube-quality-gate.json") path = Path("build/sonarqube-quality-gate.json")
if not path.exists(): if not path.exists():
print("missing") print("missing")
@ -423,7 +408,6 @@ PY
;; ;;
esac esac
fi fi
ironbank_required=0 ironbank_required=0
if enabled "${QUALITY_GATE_IRONBANK_REQUIRED:-0}"; then if enabled "${QUALITY_GATE_IRONBANK_REQUIRED:-0}"; then
ironbank_required=1 ironbank_required=1
@ -435,7 +419,6 @@ PY
supply_status="$(python3 - <<'PY' supply_status="$(python3 - <<'PY'
import json import json
from pathlib import Path from pathlib import Path
path = Path("build/ironbank-compliance.json") path = Path("build/ironbank-compliance.json")
if not path.exists(): if not path.exists():
print("missing") print("missing")
@ -445,7 +428,6 @@ try:
except Exception: # noqa: BLE001 except Exception: # noqa: BLE001
print("error") print("error")
raise SystemExit(0) raise SystemExit(0)
status = payload.get("status") status = payload.get("status")
if isinstance(status, str) and status.strip(): if isinstance(status, str) and status.strip():
print(status.strip().lower()) print(status.strip().lower())
@ -472,7 +454,6 @@ PY
;; ;;
esac esac
fi fi
if [ "${fail}" -ne 0 ]; then if [ "${fail}" -ne 0 ]; then
exit 1 exit 1
fi fi