ci: use docker instead of local stuff

This commit is contained in:
2025-07-13 20:28:35 +03:00
parent 62f066c596
commit 951018bb96

46
Jenkinsfile vendored
View File

@@ -1,5 +1,10 @@
pipeline { pipeline {
agent any agent {
docker {
image 'rust:1.75' // Use official Rust Docker image
args '-v $HOME/.cargo:/root/.cargo' // Cache Cargo dependencies
}
}
triggers { triggers {
// Trigger build on SCM changes (pushes) // Trigger build on SCM changes (pushes)
@@ -10,7 +15,6 @@ pipeline {
// Rust environment variables // Rust environment variables
CARGO_HOME = '/root/.cargo' CARGO_HOME = '/root/.cargo'
RUSTUP_HOME = '/root/.rustup' RUSTUP_HOME = '/root/.rustup'
PATH = "${env.PATH}:/root/.cargo/bin"
// Optional: Set specific Rust version // Optional: Set specific Rust version
// RUST_VERSION = '1.75.0' // RUST_VERSION = '1.75.0'
} }
@@ -23,66 +27,46 @@ pipeline {
} }
} }
stage('Setup Rust') {
steps {
script {
// Check if rustup is installed, install if not
def rustupExists = sh(script: 'test -f /root/.cargo/bin/rustup', returnStatus: true) == 0
if (!rustupExists) {
echo 'Installing rustup...'
sh 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y'
}
// Update rustup and install stable toolchain
sh '/root/.cargo/bin/rustup update stable'
sh '/root/.cargo/bin/rustup default stable'
// Install additional components
sh '/root/.cargo/bin/rustup component add clippy rustfmt'
}
}
}
stage('Rust Info') { stage('Rust Info') {
steps { steps {
// Display Rust and Cargo versions // Display Rust and Cargo versions
sh '/root/.cargo/bin/rustc --version' sh 'rustc --version'
sh '/root/.cargo/bin/cargo --version' sh 'cargo --version'
} }
} }
stage('Cache Dependencies') { stage('Cache Dependencies') {
steps { steps {
// Update Cargo index and cache dependencies // Update Cargo index and cache dependencies
sh '/root/.cargo/bin/cargo fetch' sh 'cargo fetch'
} }
} }
stage('Lint') { stage('Lint') {
steps { steps {
// Run clippy for linting // Run clippy for linting
sh '/root/.cargo/bin/cargo clippy -- -D warnings' sh 'cargo clippy -- -D warnings'
} }
} }
stage('Format Check') { stage('Format Check') {
steps { steps {
// Check code formatting // Check code formatting
sh '/root/.cargo/bin/cargo fmt -- --check' sh 'cargo fmt -- --check'
} }
} }
stage('Build') { stage('Build') {
steps { steps {
// Build the project // Build the project
sh '/root/.cargo/bin/cargo build --release' sh 'cargo build --release'
} }
} }
stage('Test') { stage('Test') {
steps { steps {
// Run tests // Run tests
sh '/root/.cargo/bin/cargo test --release' sh 'cargo test --release'
} }
} }
@@ -91,8 +75,8 @@ pipeline {
// Optional: Run security audit // Optional: Run security audit
script { script {
try { try {
sh '/root/.cargo/bin/cargo install cargo-audit || true' sh 'cargo install cargo-audit || true'
sh '/root/.cargo/bin/cargo audit' sh 'cargo audit'
} catch (Exception e) { } catch (Exception e) {
echo "Security audit failed or not available: ${e.getMessage()}" echo "Security audit failed or not available: ${e.getMessage()}"
} }