Fix stepping in Jenkinsfile

This commit is contained in:
Gamerboy59 2024-09-10 23:05:53 +02:00 committed by GitHub
commit 8d87461f21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

64
.build/Jenkinsfile vendored
View file

@ -29,14 +29,10 @@ pipeline {
}
steps {
container('rust-cargo') {
// Step to install necessary tools
step('Install Git') {
// Install git
sh 'apt-get update && apt-get -y install git --no-install-recommends'
}
// Step to clone and prepare the repository
step('Clone and Prepare Repository') {
// Clone the repository
// Clone and Prepare Repository
sh "git clone ${REPO_URL}"
dir('rust-rpxy') {
@ -47,40 +43,29 @@ pipeline {
# Initialize and update submodules
git submodule update --init
"""
}
}
// Step to extract BUILD_VERSION from Cargo.toml
step('Extract BUILD_VERSION') {
// Extract BUILD_VERSION from Cargo.toml
script {
dir('rust-rpxy') {
// Extract version from Cargo.toml and set it as an environment variable
env.BUILD_VERSION = sh(script: "grep '^version' Cargo.toml | sed -E 's/version = \"(.+)\"/\\1/'", returnStdout: true).trim()
echo "Using extracted version: ${env.BUILD_VERSION}"
}
}
}
// Step to build the binary
step('Compile Binary') {
dir('rust-rpxy') {
// Build the release version of the binary
// Build the binary
sh 'cargo build --release'
}
}
// Step to prepare and stash files
step('Prepare and Stash Files') {
// Prepare and stash files
sh """
# Move binary to workspace root for easier access
mv rust-rpxy/target/release/${BINARY_NAME} .
mv target/release/${BINARY_NAME} ..
# Move necessary files for packaging
mv rust-rpxy/.build/DEB/{control,postinst,prerm,postrm} .
mv rust-rpxy/.build/RPM/${BINARY_NAME}.spec .
mv rust-rpxy/.build/{rpxy-start.sh,config.toml,rpxy.service} .
mv rust-rpxy/{LICENSE,README.md} .
mv .build/DEB/{control,postinst,prerm,postrm} ..
mv .build/RPM/${BINARY_NAME}.spec ..
mv .build/{rpxy-start.sh,config.toml,rpxy.service} ..
mv ./{LICENSE,README.md} ..
"""
}
// Stash files for use in later stages
stash includes: "${BINARY_NAME}", name: "binary"
@ -94,7 +79,6 @@ pipeline {
}
}
}
}
stage('Build RPM Package') {
agent {
@ -115,9 +99,7 @@ pipeline {
}
steps {
container('rpm-build') {
// Step to prepare the RPM build environment
step('Prepare RPM Build Environment') {
// Unstash necessary files
// Prepare the RPM build environment
unstash 'binary'
unstash 'rpm-files'
unstash 'service-file'
@ -125,10 +107,8 @@ pipeline {
// Install necessary tools for RPM building
sh 'dnf update -y && dnf install -y rpmdevtools tar'
}
// Step to create the RPM package
step('Create RPM Package') {
// Create the RPM package
sh """
# Create RPM build directory structure
mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
@ -145,15 +125,12 @@ pipeline {
# Build the RPM package
rpmbuild --define "_topdir ${WORKSPACE}/rpmbuild" --define "_version ${BUILD_VERSION}" -bb rpmbuild/SPECS/${BINARY_NAME}.spec
"""
}
// Step to archive the RPM package
step('Archive RPM Package') {
// Archive the RPM package
archiveArtifacts artifacts: "rpmbuild/RPMS/x86_64/${BINARY_NAME}-${BUILD_VERSION}-1.el9.x86_64.rpm", allowEmptyArchive: false, fingerprint: true
}
}
}
}
stage('Build DEB Package') {
agent {
@ -174,9 +151,7 @@ pipeline {
}
steps {
container('debian-build') {
// Step to prepare the DEB build environment
step('Prepare DEB Build Environment') {
// Unstash necessary files
// Prepare the DEB build environment
unstash 'binary'
unstash 'deb-files'
unstash 'service-file'
@ -184,10 +159,8 @@ pipeline {
// Install necessary tools for DEB building
sh 'apt-get update && apt-get install -y dpkg-dev --no-install-recommends'
}
// Step to create the DEB package
step('Create DEB Package') {
// Create the DEB package
sh """
# Define DEB package directory
DEB_DIR=${BINARY_NAME}_${BUILD_VERSION}-1_amd64
@ -212,14 +185,11 @@ pipeline {
# Build the DEB package
dpkg-deb --build --root-owner-group $DEB_DIR
"""
}
// Step to archive the DEB package
step('Archive DEB Package') {
// Archive the DEB package
archiveArtifacts artifacts: "${DEB_DIR}.deb", allowEmptyArchive: false, fingerprint: true
}
}
}
}
}
}