97 lines
2.2 KiB
Groovy
97 lines
2.2 KiB
Groovy
pipeline {
|
|
agent any
|
|
|
|
options {
|
|
disableConcurrentBuilds()
|
|
}
|
|
|
|
parameters {
|
|
booleanParam(name: 'PUSH_IMAGES', defaultValue: false, description: 'Push images to registry (enable for release runs)')
|
|
string(name: 'QUALITY_GATE_PUSHGATEWAY_URL', defaultValue: 'http://platform-quality-gateway.monitoring.svc.cluster.local:9091', description: 'Pushgateway base URL for quality gate metrics')
|
|
string(name: 'REGISTRY_CREDENTIALS_ID', defaultValue: 'registry-bstein-dev', description: 'Jenkins credentials id for registry.bstein.dev')
|
|
}
|
|
|
|
environment {
|
|
REGISTRY = 'registry.bstein.dev'
|
|
IMAGE_PREFIX = "${REGISTRY}/lesavka"
|
|
CARGO_TERM_COLOR = 'always'
|
|
DOCKER_BUILDKIT = '1'
|
|
}
|
|
|
|
stages {
|
|
stage('Checkout') {
|
|
steps {
|
|
checkout scm
|
|
}
|
|
}
|
|
|
|
stage('Format') {
|
|
steps {
|
|
sh 'cargo fmt --all -- --check'
|
|
}
|
|
}
|
|
|
|
stage('Hygiene') {
|
|
steps {
|
|
sh 'scripts/ci/hygiene_gate.sh'
|
|
}
|
|
}
|
|
|
|
stage('Testing') {
|
|
steps {
|
|
sh 'cargo test -p lesavka_testing'
|
|
}
|
|
}
|
|
|
|
stage('Quality Gate') {
|
|
steps {
|
|
sh 'QUALITY_GATE_PUSHGATEWAY_URL="${QUALITY_GATE_PUSHGATEWAY_URL}" scripts/ci/quality_gate.sh'
|
|
}
|
|
}
|
|
|
|
stage('Build Dist') {
|
|
steps {
|
|
sh 'scripts/ci/build-dist.sh'
|
|
}
|
|
}
|
|
|
|
stage('Docker Login') {
|
|
when {
|
|
expression { return params.PUSH_IMAGES }
|
|
}
|
|
steps {
|
|
withCredentials([
|
|
usernamePassword(
|
|
credentialsId: params.REGISTRY_CREDENTIALS_ID,
|
|
usernameVariable: 'REGISTRY_USER',
|
|
passwordVariable: 'REGISTRY_PASS'
|
|
)
|
|
]) {
|
|
sh 'echo "$REGISTRY_PASS" | docker login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin'
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Build Images') {
|
|
when {
|
|
expression { return params.PUSH_IMAGES }
|
|
}
|
|
steps {
|
|
sh 'PUSH_IMAGES=${PUSH_IMAGES} scripts/ci/build-images.sh'
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
always {
|
|
script {
|
|
try {
|
|
archiveArtifacts artifacts: 'dist/*.tar.gz', fingerprint: true, allowEmptyArchive: true
|
|
} catch (Throwable err) {
|
|
echo "archive step unavailable: ${err.class.simpleName}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|