vsg-bridge-ls/Jenkinsfile

145 lines
3.5 KiB
Groovy

// Add this webhook in Gitea:
// http://192.168.1.37:8080/gitea-webhook/post
pipeline {
agent { label 'rust_nodocker' }
environment {
CARGO_TERM_COLOR = 'never'
RUST_BACKTRACE = '1'
}
stages {
stage('Checkout') {
steps {
checkout scm
sh '''
set -eu
git submodule sync --recursive
git submodule update --init --recursive
'''
}
}
stage('Setup Rust') {
steps {
sh '''
set -eu
if ! command -v rustup >/dev/null 2>&1; then
echo "ERROR: rustup is not installed on this worker." >&2
exit 1
fi
rustup toolchain install stable \
--profile minimal \
--component rustfmt \
--component clippy
rustup default stable
echo
rustc --version
cargo --version
'''
}
}
stage('Format') {
steps {
sh '''
set -eu
echo "Checking formatting..."
cargo fmt \
--all \
-- \
--check
'''
}
}
stage('Check') {
steps {
sh '''
set -eu
echo "Running cargo check..."
cargo check \
--all-targets \
--all-features
'''
}
}
stage('Tests') {
steps {
sh '''
set -eu
echo "Running tests..."
cargo test \
--all-targets \
--all-features
'''
}
}
stage('Clippy') {
steps {
sh '''
set -eu
echo "Running Clippy..."
cargo clippy \
--all-targets \
--all-features
'''
}
}
}
post {
success {
publishChecks(
conclusion: 'SUCCESS',
name: 'Rust CI',
summary: 'vsg_bridge_ls passed CI.',
text: 'Formatting, cargo check, tests, and Clippy completed successfully.',
title: 'Build Successful'
)
echo '✅ vsg_bridge_ls passed CI.'
}
failure {
publishChecks(
conclusion: 'FAILURE',
name: 'Rust CI',
summary: 'vsg_bridge_ls failed CI.',
text: 'Formatting, cargo check, tests, or Clippy failed. Check the Jenkins log.',
title: 'Build Failed'
)
echo '❌ vsg_bridge_ls CI failed.'
}
unstable {
publishChecks(
conclusion: 'ACTION_REQUIRED',
name: 'Rust CI',
summary: 'vsg_bridge_ls CI is unstable.',
text: 'The Jenkins build completed with an unstable status.',
title: 'Build Unstable'
)
echo '⚠️ vsg_bridge_ls CI is unstable.'
}
}
}