2026-03-31 14:52:50 -03:00
|
|
|
pipeline {
|
|
|
|
|
agent {
|
|
|
|
|
kubernetes {
|
|
|
|
|
defaultContainer 'builder'
|
|
|
|
|
yaml """
|
|
|
|
|
apiVersion: v1
|
|
|
|
|
kind: Pod
|
|
|
|
|
metadata:
|
|
|
|
|
labels:
|
|
|
|
|
app: metis
|
|
|
|
|
spec:
|
|
|
|
|
nodeSelector:
|
|
|
|
|
kubernetes.io/arch: arm64
|
|
|
|
|
node-role.kubernetes.io/worker: "true"
|
|
|
|
|
imagePullSecrets:
|
|
|
|
|
- name: harbor-robot-pipeline
|
|
|
|
|
containers:
|
|
|
|
|
- name: dind
|
2026-04-21 13:36:52 -03:00
|
|
|
image: registry.bstein.dev/bstein/docker:27-dind
|
2026-03-31 14:52:50 -03:00
|
|
|
securityContext:
|
|
|
|
|
privileged: true
|
|
|
|
|
env:
|
|
|
|
|
- name: DOCKER_TLS_CERTDIR
|
|
|
|
|
value: ""
|
|
|
|
|
args:
|
|
|
|
|
- --mtu=1400
|
|
|
|
|
- --host=unix:///var/run/docker.sock
|
|
|
|
|
- --host=tcp://0.0.0.0:2375
|
2026-04-05 14:41:37 -03:00
|
|
|
- --tls=false
|
2026-03-31 14:52:50 -03:00
|
|
|
volumeMounts:
|
|
|
|
|
- name: dind-storage
|
|
|
|
|
mountPath: /var/lib/docker
|
|
|
|
|
- name: builder
|
2026-04-21 13:36:52 -03:00
|
|
|
image: registry.bstein.dev/bstein/docker:27
|
2026-03-31 14:52:50 -03:00
|
|
|
command: ["cat"]
|
|
|
|
|
tty: true
|
|
|
|
|
env:
|
|
|
|
|
- name: DOCKER_HOST
|
|
|
|
|
value: tcp://localhost:2375
|
|
|
|
|
- name: DOCKER_TLS_CERTDIR
|
|
|
|
|
value: ""
|
|
|
|
|
- name: DOCKER_CONFIG
|
|
|
|
|
value: /root/.docker
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: workspace-volume
|
|
|
|
|
mountPath: /home/jenkins/agent
|
|
|
|
|
- name: docker-config-writable
|
|
|
|
|
mountPath: /root/.docker
|
|
|
|
|
- name: harbor-config
|
|
|
|
|
mountPath: /docker-config
|
|
|
|
|
- name: tester
|
2026-04-21 13:36:52 -03:00
|
|
|
image: registry.bstein.dev/bstein/golang:1.23-bookworm
|
2026-03-31 14:52:50 -03:00
|
|
|
command: ["cat"]
|
|
|
|
|
tty: true
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: workspace-volume
|
|
|
|
|
mountPath: /home/jenkins/agent
|
|
|
|
|
- name: publisher
|
2026-04-21 13:17:35 -03:00
|
|
|
image: registry.bstein.dev/bstein/python:3.12-slim
|
2026-03-31 14:52:50 -03:00
|
|
|
command: ["cat"]
|
|
|
|
|
tty: true
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: workspace-volume
|
|
|
|
|
mountPath: /home/jenkins/agent
|
2026-04-21 22:09:05 -03:00
|
|
|
- name: quality-tools
|
|
|
|
|
image: registry.bstein.dev/bstein/quality-tools:sonar8.0.1-trivy0.70.0-arm64
|
|
|
|
|
command: ["cat"]
|
|
|
|
|
tty: true
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: workspace-volume
|
|
|
|
|
mountPath: /home/jenkins/agent
|
2026-03-31 14:52:50 -03:00
|
|
|
volumes:
|
|
|
|
|
- name: workspace-volume
|
|
|
|
|
emptyDir: {}
|
|
|
|
|
- name: docker-config-writable
|
|
|
|
|
emptyDir: {}
|
|
|
|
|
- name: dind-storage
|
2026-04-10 06:24:33 -03:00
|
|
|
emptyDir: {}
|
2026-03-31 14:52:50 -03:00
|
|
|
- name: harbor-config
|
|
|
|
|
secret:
|
|
|
|
|
secretName: harbor-robot-pipeline
|
|
|
|
|
items:
|
|
|
|
|
- key: .dockerconfigjson
|
|
|
|
|
path: config.json
|
|
|
|
|
"""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
environment {
|
|
|
|
|
REGISTRY = 'registry.bstein.dev/bstein'
|
|
|
|
|
IMAGE = "${REGISTRY}/metis"
|
|
|
|
|
SENTINEL_IMAGE = "${REGISTRY}/metis-sentinel"
|
|
|
|
|
VERSION_TAG = 'dev'
|
|
|
|
|
SEMVER = 'dev'
|
|
|
|
|
COVERAGE_JSON = 'build/coverage.json'
|
|
|
|
|
JUNIT_XML = 'build/junit.xml'
|
2026-04-10 13:47:32 -03:00
|
|
|
TEST_EXIT_CODE_PATH = 'build/test.exitcode'
|
2026-04-10 05:59:52 -03:00
|
|
|
SUITE_NAME = 'metis'
|
|
|
|
|
PUSHGATEWAY_URL = 'http://platform-quality-gateway.monitoring.svc.cluster.local:9091'
|
2026-04-21 20:16:19 -03:00
|
|
|
SONARQUBE_HOST_URL = 'http://sonarqube.quality.svc.cluster.local:9000'
|
|
|
|
|
SONARQUBE_PROJECT_KEY = 'metis'
|
|
|
|
|
SONARQUBE_TOKEN = credentials('sonarqube-token')
|
2026-04-19 14:10:50 -03:00
|
|
|
QUALITY_GATE_SONARQUBE_REPORT = 'build/sonarqube-quality-gate.json'
|
|
|
|
|
QUALITY_GATE_IRONBANK_REPORT = 'build/ironbank-compliance.json'
|
2026-03-31 14:52:50 -03:00
|
|
|
}
|
|
|
|
|
options {
|
|
|
|
|
disableConcurrentBuilds()
|
2026-04-20 12:58:51 -03:00
|
|
|
buildDiscarder(logRotator(daysToKeepStr: '30', numToKeepStr: '200', artifactDaysToKeepStr: '30', artifactNumToKeepStr: '120'))
|
2026-03-31 14:52:50 -03:00
|
|
|
}
|
2026-04-19 14:10:50 -03:00
|
|
|
parameters {
|
|
|
|
|
booleanParam(
|
|
|
|
|
name: 'PUBLISH_IMAGES',
|
|
|
|
|
defaultValue: false,
|
|
|
|
|
description: 'Build and push runtime images (enable for release runs).'
|
|
|
|
|
)
|
|
|
|
|
}
|
2026-03-31 14:52:50 -03:00
|
|
|
triggers {
|
|
|
|
|
pollSCM('H/5 * * * *')
|
|
|
|
|
}
|
|
|
|
|
stages {
|
|
|
|
|
stage('Checkout') {
|
|
|
|
|
steps {
|
|
|
|
|
checkout scm
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-19 14:10:50 -03:00
|
|
|
stage('Collect SonarQube evidence') {
|
|
|
|
|
steps {
|
2026-04-21 22:09:05 -03:00
|
|
|
container('quality-tools') {
|
|
|
|
|
sh '''#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
mkdir -p build
|
|
|
|
|
args=(
|
|
|
|
|
"-Dsonar.host.url=${SONARQUBE_HOST_URL}"
|
2026-04-21 22:17:54 -03:00
|
|
|
"-Dsonar.login=${SONARQUBE_TOKEN}"
|
2026-04-21 22:09:05 -03:00
|
|
|
"-Dsonar.projectKey=${SONARQUBE_PROJECT_KEY}"
|
|
|
|
|
"-Dsonar.projectName=${SONARQUBE_PROJECT_KEY}"
|
|
|
|
|
"-Dsonar.sources=."
|
|
|
|
|
"-Dsonar.exclusions=**/.git/**,**/build/**,**/dist/**,**/node_modules/**,**/.venv/**,**/__pycache__/**,**/coverage/**,**/test-results/**,**/playwright-report/**"
|
|
|
|
|
"-Dsonar.test.inclusions=**/tests/**,**/testing/**,**/*_test.go,**/*.test.ts,**/*.test.tsx,**/*.spec.ts,**/*.spec.tsx"
|
|
|
|
|
)
|
|
|
|
|
[ -f build/coverage.out ] && args+=("-Dsonar.go.coverage.reportPaths=build/coverage.out")
|
|
|
|
|
set +e
|
|
|
|
|
sonar-scanner "${args[@]}" | tee build/sonar-scanner.log
|
|
|
|
|
rc=${PIPESTATUS[0]}
|
|
|
|
|
set -e
|
|
|
|
|
printf '%s\n' "${rc}" > build/sonarqube-analysis.rc
|
|
|
|
|
'''
|
|
|
|
|
}
|
2026-04-19 14:10:50 -03:00
|
|
|
container('publisher') {
|
|
|
|
|
sh '''
|
|
|
|
|
set -eu
|
|
|
|
|
mkdir -p build
|
|
|
|
|
python3 - <<'PY'
|
|
|
|
|
import base64
|
|
|
|
|
import json
|
|
|
|
|
import os
|
|
|
|
|
import urllib.parse
|
|
|
|
|
import urllib.request
|
|
|
|
|
|
|
|
|
|
host = os.getenv('SONARQUBE_HOST_URL', '').strip().rstrip('/')
|
|
|
|
|
project_key = os.getenv('SONARQUBE_PROJECT_KEY', '').strip()
|
|
|
|
|
token = os.getenv('SONARQUBE_TOKEN', '').strip()
|
|
|
|
|
report_path = os.getenv('QUALITY_GATE_SONARQUBE_REPORT', 'build/sonarqube-quality-gate.json')
|
|
|
|
|
payload = {"status": "ERROR", "note": "missing SONARQUBE_HOST_URL and/or SONARQUBE_PROJECT_KEY"}
|
|
|
|
|
if host and project_key:
|
|
|
|
|
query = urllib.parse.urlencode({"projectKey": project_key})
|
|
|
|
|
request = urllib.request.Request(f"{host}/api/qualitygates/project_status?{query}", method="GET")
|
|
|
|
|
if token:
|
|
|
|
|
encoded = base64.b64encode(f"{token}:".encode("utf-8")).decode("utf-8")
|
|
|
|
|
request.add_header("Authorization", f"Basic {encoded}")
|
|
|
|
|
try:
|
|
|
|
|
with urllib.request.urlopen(request, timeout=12) as response:
|
|
|
|
|
payload = json.loads(response.read().decode("utf-8"))
|
|
|
|
|
except Exception as exc: # noqa: BLE001
|
|
|
|
|
payload = {"status": "ERROR", "error": str(exc)}
|
|
|
|
|
with open(report_path, "w", encoding="utf-8") as handle:
|
|
|
|
|
json.dump(payload, handle, indent=2, sort_keys=True)
|
|
|
|
|
handle.write("\\n")
|
|
|
|
|
PY
|
|
|
|
|
'''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Collect Supply Chain evidence') {
|
|
|
|
|
steps {
|
2026-04-21 22:09:05 -03:00
|
|
|
container('quality-tools') {
|
|
|
|
|
sh '''#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
mkdir -p build
|
|
|
|
|
set +e
|
|
|
|
|
trivy fs --no-progress --format json --output build/trivy-fs.json --scanners vuln,secret,misconfig --severity HIGH,CRITICAL .
|
|
|
|
|
trivy_rc=$?
|
|
|
|
|
set -e
|
|
|
|
|
if [ ! -s build/trivy-fs.json ]; then
|
|
|
|
|
cat > build/ironbank-compliance.json <<EOF
|
|
|
|
|
{"status":"failed","compliant":false,"scanner":"trivy","scan_type":"filesystem","error":"trivy did not produce JSON output","trivy_rc":${trivy_rc}}
|
|
|
|
|
EOF
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
critical="$(jq '[.Results[]? | .Vulnerabilities[]? | select(.Severity=="CRITICAL")] | length' build/trivy-fs.json)"
|
|
|
|
|
high="$(jq '[.Results[]? | .Vulnerabilities[]? | select(.Severity=="HIGH")] | length' build/trivy-fs.json)"
|
|
|
|
|
secrets="$(jq '[.Results[]? | .Secrets[]?] | length' build/trivy-fs.json)"
|
|
|
|
|
misconfigs="$(jq '[.Results[]? | .Misconfigurations[]? | select(.Status=="FAIL" and (.Severity=="CRITICAL" or .Severity=="HIGH"))] | length' build/trivy-fs.json)"
|
|
|
|
|
status=ok
|
|
|
|
|
compliant=true
|
|
|
|
|
if [ "${critical}" -gt 0 ] || [ "${secrets}" -gt 0 ] || [ "${misconfigs}" -gt 0 ]; then
|
|
|
|
|
status=failed
|
|
|
|
|
compliant=false
|
|
|
|
|
fi
|
|
|
|
|
jq -n --arg status "${status}" --argjson compliant "${compliant}" --argjson critical "${critical}" --argjson high "${high}" --argjson secrets "${secrets}" --argjson misconfigs "${misconfigs}" --argjson trivy_rc "${trivy_rc}" \
|
|
|
|
|
'{status:$status, compliant:$compliant, category:"artifact_security", scan_type:"filesystem", scanner:"trivy", critical_vulnerabilities:$critical, high_vulnerabilities:$high, secrets:$secrets, high_or_critical_misconfigurations:$misconfigs, trivy_rc:$trivy_rc, high_vulnerability_policy:"observe"}' > build/ironbank-compliance.json
|
|
|
|
|
'''
|
|
|
|
|
}
|
2026-04-19 14:10:50 -03:00
|
|
|
container('publisher') {
|
|
|
|
|
sh '''
|
|
|
|
|
set -eu
|
|
|
|
|
mkdir -p build
|
|
|
|
|
python3 - <<'PY'
|
|
|
|
|
import json
|
|
|
|
|
import os
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
report_path = Path(os.getenv('QUALITY_GATE_IRONBANK_REPORT', 'build/ironbank-compliance.json'))
|
|
|
|
|
if report_path.exists():
|
|
|
|
|
raise SystemExit(0)
|
|
|
|
|
status = os.getenv('IRONBANK_COMPLIANCE_STATUS', '').strip()
|
|
|
|
|
compliant = os.getenv('IRONBANK_COMPLIANT', '').strip().lower()
|
|
|
|
|
payload = {"status": status or "unknown", "compliant": compliant in {"1", "true", "yes", "on"} if compliant else None}
|
|
|
|
|
payload = {k: v for k, v in payload.items() if v is not None}
|
|
|
|
|
if "status" not in payload:
|
|
|
|
|
payload["status"] = "unknown"
|
|
|
|
|
payload["note"] = "Set IRONBANK_COMPLIANCE_STATUS/IRONBANK_COMPLIANT or write build/ironbank-compliance.json in image-building repos."
|
|
|
|
|
report_path.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
report_path.write_text(json.dumps(payload, indent=2, sort_keys=True) + "\\n", encoding="utf-8")
|
|
|
|
|
PY
|
|
|
|
|
'''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Run quality gate') {
|
2026-03-31 14:52:50 -03:00
|
|
|
steps {
|
|
|
|
|
container('tester') {
|
|
|
|
|
sh '''
|
2026-04-05 14:07:31 -03:00
|
|
|
set -eu
|
2026-03-31 14:52:50 -03:00
|
|
|
apt-get update >/dev/null
|
|
|
|
|
apt-get install -y --no-install-recommends xz-utils >/dev/null
|
|
|
|
|
mkdir -p build
|
2026-04-21 10:51:55 -03:00
|
|
|
export GOPROXY="${GOPROXY:-https://proxy.golang.org,direct}"
|
|
|
|
|
retry_command() {
|
|
|
|
|
attempts=4
|
|
|
|
|
delay=8
|
|
|
|
|
attempt=1
|
|
|
|
|
while [ "${attempt}" -le "${attempts}" ]; do
|
2026-04-21 14:52:04 -03:00
|
|
|
if "$@"; then
|
2026-04-21 10:51:55 -03:00
|
|
|
return 0
|
|
|
|
|
fi
|
2026-04-21 14:52:04 -03:00
|
|
|
rc=$?
|
2026-04-21 10:51:55 -03:00
|
|
|
if [ "${attempt}" -eq "${attempts}" ]; then
|
|
|
|
|
return "${rc}"
|
|
|
|
|
fi
|
|
|
|
|
echo "command failed with rc=${rc}; retrying in ${delay}s (${attempt}/${attempts})"
|
|
|
|
|
sleep "${delay}"
|
|
|
|
|
delay=$((delay * 2))
|
|
|
|
|
attempt=$((attempt + 1))
|
|
|
|
|
done
|
|
|
|
|
}
|
2026-04-21 14:43:49 -03:00
|
|
|
retry_command go install github.com/jstemmer/go-junit-report/v2@latest
|
2026-04-20 12:58:51 -03:00
|
|
|
cd "${WORKSPACE}"
|
|
|
|
|
docs_rc=1
|
|
|
|
|
quality_rc=1
|
|
|
|
|
test_rc=1
|
|
|
|
|
|
2026-03-31 14:52:50 -03:00
|
|
|
set +e
|
2026-04-20 12:58:51 -03:00
|
|
|
cd "${WORKSPACE}/testing"
|
2026-04-21 10:51:55 -03:00
|
|
|
retry_command env METIS_USE_EXISTING_COVERAGE=1 go test -v -run TestExportedDocs ./...
|
2026-04-20 12:58:51 -03:00
|
|
|
docs_rc=$?
|
|
|
|
|
printf '%s\n' "${docs_rc}" > "${WORKSPACE}/build/docs-naming.rc"
|
|
|
|
|
if [ "${docs_rc}" -eq 0 ]; then
|
2026-04-21 10:51:55 -03:00
|
|
|
retry_command env METIS_USE_EXISTING_COVERAGE=1 go test -v ./...
|
2026-04-20 12:58:51 -03:00
|
|
|
quality_rc=$?
|
|
|
|
|
fi
|
|
|
|
|
cd "${WORKSPACE}"
|
|
|
|
|
|
|
|
|
|
if [ "${docs_rc}" -eq 0 ] && [ "${quality_rc}" -eq 0 ]; then
|
2026-04-21 10:51:55 -03:00
|
|
|
retry_command go test -v -count=1 -coverprofile=build/coverage.out ./... > build/test.out 2>&1
|
2026-04-20 12:58:51 -03:00
|
|
|
test_rc=$?
|
|
|
|
|
fi
|
2026-03-31 14:52:50 -03:00
|
|
|
set -e
|
2026-04-20 12:58:51 -03:00
|
|
|
|
|
|
|
|
if [ -f build/test.out ]; then
|
|
|
|
|
cat build/test.out
|
|
|
|
|
"$(go env GOPATH)/bin/go-junit-report" < build/test.out > "${JUNIT_XML}"
|
|
|
|
|
else
|
|
|
|
|
cat > "${JUNIT_XML}" <<'EOF'
|
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<testsuites tests="0" failures="0" errors="0" skipped="0"></testsuites>
|
|
|
|
|
EOF
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-31 14:52:50 -03:00
|
|
|
coverage="0"
|
|
|
|
|
if [ -f build/coverage.out ]; then
|
|
|
|
|
coverage="$(go tool cover -func=build/coverage.out | awk '/^total:/ {gsub("%","",$3); print $3}')"
|
|
|
|
|
fi
|
|
|
|
|
export GO_COVERAGE="${coverage}"
|
2026-04-05 14:14:23 -03:00
|
|
|
printf '{"summary":{"percent_covered":%s}}\n' "${GO_COVERAGE}" > "${COVERAGE_JSON}"
|
2026-04-19 14:10:50 -03:00
|
|
|
|
|
|
|
|
gate_rc=0
|
2026-04-20 12:58:51 -03:00
|
|
|
if [ "${docs_rc}" -ne 0 ] || [ "${quality_rc}" -ne 0 ] || [ "${test_rc}" -ne 0 ]; then
|
2026-04-19 14:10:50 -03:00
|
|
|
gate_rc=1
|
|
|
|
|
fi
|
|
|
|
|
printf '%s\n' "${gate_rc}" > "${TEST_EXIT_CODE_PATH}"
|
2026-03-31 14:52:50 -03:00
|
|
|
'''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Publish test metrics') {
|
|
|
|
|
steps {
|
|
|
|
|
container('publisher') {
|
|
|
|
|
sh '''
|
2026-04-05 14:07:31 -03:00
|
|
|
set -eu
|
2026-03-31 14:52:50 -03:00
|
|
|
python scripts/publish_test_metrics.py
|
|
|
|
|
'''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-19 14:10:50 -03:00
|
|
|
stage('Enforce quality gate') {
|
2026-04-10 13:47:32 -03:00
|
|
|
steps {
|
|
|
|
|
container('tester') {
|
|
|
|
|
sh '''
|
|
|
|
|
set -eu
|
|
|
|
|
test_rc="$(cat "${TEST_EXIT_CODE_PATH}")"
|
|
|
|
|
exit "${test_rc}"
|
|
|
|
|
'''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 14:52:50 -03:00
|
|
|
stage('Prep toolchain') {
|
2026-04-19 14:10:50 -03:00
|
|
|
when {
|
|
|
|
|
expression { return params.PUBLISH_IMAGES }
|
|
|
|
|
}
|
2026-03-31 14:52:50 -03:00
|
|
|
steps {
|
|
|
|
|
container('builder') {
|
|
|
|
|
sh '''
|
2026-04-05 14:07:31 -03:00
|
|
|
set -eu
|
2026-03-31 14:52:50 -03:00
|
|
|
mkdir -p /root/.docker
|
|
|
|
|
cp /docker-config/config.json /root/.docker/config.json
|
|
|
|
|
'''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Compute version') {
|
2026-04-19 14:10:50 -03:00
|
|
|
when {
|
|
|
|
|
expression { return params.PUBLISH_IMAGES }
|
|
|
|
|
}
|
2026-03-31 14:52:50 -03:00
|
|
|
steps {
|
|
|
|
|
container('builder') {
|
|
|
|
|
script {
|
|
|
|
|
sh '''
|
2026-04-05 14:07:31 -03:00
|
|
|
set -eu
|
2026-03-31 14:52:50 -03:00
|
|
|
SEMVER="0.1.0-${BUILD_NUMBER}"
|
|
|
|
|
echo "SEMVER=${SEMVER}" > build.env
|
|
|
|
|
'''
|
|
|
|
|
def props = readProperties file: 'build.env'
|
|
|
|
|
env.SEMVER = props['SEMVER'] ?: "0.1.0-${env.BUILD_NUMBER}"
|
|
|
|
|
env.VERSION_TAG = env.SEMVER
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Buildx setup') {
|
2026-04-19 14:10:50 -03:00
|
|
|
when {
|
|
|
|
|
expression { return params.PUBLISH_IMAGES }
|
|
|
|
|
}
|
2026-03-31 14:52:50 -03:00
|
|
|
steps {
|
|
|
|
|
container('builder') {
|
|
|
|
|
sh '''
|
2026-04-05 14:07:31 -03:00
|
|
|
set -eu
|
2026-04-05 14:41:37 -03:00
|
|
|
ready=0
|
|
|
|
|
for i in $(seq 1 90); do
|
2026-03-31 14:52:50 -03:00
|
|
|
if docker info >/dev/null 2>&1; then
|
2026-04-05 14:41:37 -03:00
|
|
|
ready=1
|
2026-03-31 14:52:50 -03:00
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
sleep 2
|
|
|
|
|
done
|
2026-04-05 14:41:37 -03:00
|
|
|
if [ "${ready}" -ne 1 ]; then
|
|
|
|
|
echo "docker daemon did not become ready on ${DOCKER_HOST}"
|
|
|
|
|
docker version || true
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2026-04-05 14:57:52 -03:00
|
|
|
docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64
|
2026-04-10 06:24:33 -03:00
|
|
|
BUILDER_NAME="metis-builder-${BUILD_NUMBER}"
|
|
|
|
|
docker buildx rm "${BUILDER_NAME}" >/dev/null 2>&1 || true
|
2026-04-21 17:35:54 -03:00
|
|
|
docker buildx create --name "${BUILDER_NAME}" --driver docker-container --driver-opt image=registry.bstein.dev/bstein/buildkit:buildx-stable-1 --use
|
2026-04-10 06:24:33 -03:00
|
|
|
docker buildx inspect "${BUILDER_NAME}" --bootstrap
|
2026-03-31 14:52:50 -03:00
|
|
|
'''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 15:44:37 -03:00
|
|
|
stage('Build & push images') {
|
2026-04-19 14:10:50 -03:00
|
|
|
when {
|
|
|
|
|
expression { return params.PUBLISH_IMAGES }
|
|
|
|
|
}
|
2026-03-31 14:52:50 -03:00
|
|
|
steps {
|
|
|
|
|
container('builder') {
|
|
|
|
|
sh '''
|
2026-04-05 14:07:31 -03:00
|
|
|
set -eu
|
2026-03-31 14:52:50 -03:00
|
|
|
VERSION_TAG="$(cut -d= -f2 build.env)"
|
2026-04-05 14:41:37 -03:00
|
|
|
docker info >/dev/null
|
2026-03-31 15:44:37 -03:00
|
|
|
for arch in amd64 arm64; do
|
|
|
|
|
docker buildx build \
|
|
|
|
|
--platform "linux/${arch}" \
|
|
|
|
|
--build-arg TARGETOS=linux \
|
|
|
|
|
--build-arg TARGETARCH="${arch}" \
|
|
|
|
|
--tag "${IMAGE}:${VERSION_TAG}-${arch}" \
|
|
|
|
|
--tag "${IMAGE}:latest-${arch}" \
|
|
|
|
|
--target runtime \
|
|
|
|
|
--push \
|
|
|
|
|
.
|
|
|
|
|
docker buildx build \
|
|
|
|
|
--platform "linux/${arch}" \
|
|
|
|
|
--build-arg TARGETOS=linux \
|
|
|
|
|
--build-arg TARGETARCH="${arch}" \
|
|
|
|
|
--tag "${SENTINEL_IMAGE}:${VERSION_TAG}-${arch}" \
|
|
|
|
|
--tag "${SENTINEL_IMAGE}:latest-${arch}" \
|
|
|
|
|
--target sentinel \
|
|
|
|
|
--push \
|
|
|
|
|
.
|
|
|
|
|
done
|
2026-03-31 14:52:50 -03:00
|
|
|
'''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
post {
|
|
|
|
|
always {
|
|
|
|
|
script {
|
|
|
|
|
if (fileExists('build/junit.xml')) {
|
|
|
|
|
try {
|
|
|
|
|
junit allowEmptyResults: true, testResults: 'build/junit.xml'
|
|
|
|
|
} catch (Throwable err) {
|
|
|
|
|
echo "junit step unavailable: ${err.class.simpleName}"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-21 09:21:56 -03:00
|
|
|
archiveArtifacts artifacts: 'build/**', allowEmptyArchive: true, fingerprint: true
|
2026-03-31 14:52:50 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|