ci: shim docker version and publish quality gate status
This commit is contained in:
parent
515a0ea516
commit
0afa6e1b6d
71
Jenkinsfile
vendored
71
Jenkinsfile
vendored
@ -59,6 +59,8 @@ spec:
|
|||||||
IMAGE_NAMESPACE = 'registry.bstein.dev/infra'
|
IMAGE_NAMESPACE = 'registry.bstein.dev/infra'
|
||||||
TAG_SUFFIX = '-arm64'
|
TAG_SUFFIX = '-arm64'
|
||||||
REGISTRY_URL = 'registry.bstein.dev'
|
REGISTRY_URL = 'registry.bstein.dev'
|
||||||
|
SUITE_NAME = 'harbor-arm-build'
|
||||||
|
PUSHGATEWAY_URL = 'http://platform-quality-gateway.monitoring.svc.cluster.local:9091'
|
||||||
}
|
}
|
||||||
options {
|
options {
|
||||||
disableConcurrentBuilds()
|
disableConcurrentBuilds()
|
||||||
@ -80,6 +82,17 @@ spec:
|
|||||||
cp /docker-config/config.json "${DOCKER_CONFIG}/config.json"
|
cp /docker-config/config.json "${DOCKER_CONFIG}/config.json"
|
||||||
# Make the Docker CLI invoke podman (buildah backend).
|
# Make the Docker CLI invoke podman (buildah backend).
|
||||||
ln -sf /usr/bin/podman /usr/local/bin/docker
|
ln -sf /usr/bin/podman /usr/local/bin/docker
|
||||||
|
# Harbor's build scripts parse `docker --version`; emulate Docker output so
|
||||||
|
# environment checks pass while still delegating real commands to podman.
|
||||||
|
cat > /usr/local/bin/docker <<'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "version" ]; then
|
||||||
|
echo "Docker version 24.0.0, build podman-shim"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
exec /usr/bin/podman "$@"
|
||||||
|
EOF
|
||||||
|
chmod +x /usr/local/bin/docker
|
||||||
mkdir -p "${XDG_RUNTIME_DIR}"
|
mkdir -p "${XDG_RUNTIME_DIR}"
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
@ -197,6 +210,64 @@ spec:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
|
success {
|
||||||
|
container('builder') {
|
||||||
|
sh '''
|
||||||
|
set -euo pipefail
|
||||||
|
suite="${SUITE_NAME}"
|
||||||
|
gateway="${PUSHGATEWAY_URL}"
|
||||||
|
fetch_counter() {
|
||||||
|
status="$1"
|
||||||
|
line="$(curl -fsS "${gateway}/metrics" 2>/dev/null | awk -v suite="${suite}" -v status="${status}" '
|
||||||
|
/^platform_quality_gate_runs_total\{/ {
|
||||||
|
if (index($0, "job=\\"platform-quality-ci\\"") && index($0, "suite=\\"" suite "\\"") && index($0, "status=\\"" status "\\"")) {
|
||||||
|
print $2
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' || true)"
|
||||||
|
[ -n "${line}" ] && printf '%s\n' "${line}" || printf '0\n'
|
||||||
|
}
|
||||||
|
ok_count="$(fetch_counter ok)"
|
||||||
|
failed_count="$(fetch_counter failed)"
|
||||||
|
ok_count=$((ok_count + 1))
|
||||||
|
cat <<METRICS | curl -fsS --data-binary @- "${gateway}/metrics/job/platform-quality-ci/suite/${suite}" >/dev/null
|
||||||
|
# TYPE platform_quality_gate_runs_total counter
|
||||||
|
platform_quality_gate_runs_total{suite="${suite}",status="ok"} ${ok_count}
|
||||||
|
platform_quality_gate_runs_total{suite="${suite}",status="failed"} ${failed_count}
|
||||||
|
METRICS
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
container('builder') {
|
||||||
|
sh '''
|
||||||
|
set -euo pipefail
|
||||||
|
suite="${SUITE_NAME}"
|
||||||
|
gateway="${PUSHGATEWAY_URL}"
|
||||||
|
fetch_counter() {
|
||||||
|
status="$1"
|
||||||
|
line="$(curl -fsS "${gateway}/metrics" 2>/dev/null | awk -v suite="${suite}" -v status="${status}" '
|
||||||
|
/^platform_quality_gate_runs_total\{/ {
|
||||||
|
if (index($0, "job=\\"platform-quality-ci\\"") && index($0, "suite=\\"" suite "\\"") && index($0, "status=\\"" status "\\"")) {
|
||||||
|
print $2
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' || true)"
|
||||||
|
[ -n "${line}" ] && printf '%s\n' "${line}" || printf '0\n'
|
||||||
|
}
|
||||||
|
ok_count="$(fetch_counter ok)"
|
||||||
|
failed_count="$(fetch_counter failed)"
|
||||||
|
failed_count=$((failed_count + 1))
|
||||||
|
cat <<METRICS | curl -fsS --data-binary @- "${gateway}/metrics/job/platform-quality-ci/suite/${suite}" >/dev/null
|
||||||
|
# TYPE platform_quality_gate_runs_total counter
|
||||||
|
platform_quality_gate_runs_total{suite="${suite}",status="ok"} ${ok_count}
|
||||||
|
platform_quality_gate_runs_total{suite="${suite}",status="failed"} ${failed_count}
|
||||||
|
METRICS
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
always {
|
always {
|
||||||
echo "done"
|
echo "done"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user