Yerbacon/Jenkinsfile

53 lines
3.0 KiB
Groovy

def buildTarget(String path, String rpmArch, String debArch, String isPackageArchDeb = true) {
String packageArch = isPackageArchDeb ? debArch : rpmArch;
cmakeBuild buildDir: "cmake-build-${debArch}", buildType: 'release', cleanBuild: true, installation: 'Main',
cmakeArgs: "-DCMAKE_C_COMPILER=/usr/bin/${path}-gcc -DCMAKE_CXX_COMPILER=/usr/bin/${path}-g++ -DCMAKE_LINKER=/usr/bin/${path}-ld.gold -DCMAKE_AR=/usr/bin/${path}-ar -DCPACK_RPM_PACKAGE_ARCHITECTURE=${rpmArch} -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=${debArch} -DCXX_TARGET=${packageArch}"
cmake arguments: "--build ./cmake-build-${debArch} --target ybcon", installation: 'Main'
cpack installation: 'Main', workingDir: "cmake-build-${debArch}"
}
pipeline { // Multi-branch pipeline script for Yerbacon.
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '48', artifactNumToKeepStr: '96'))
timeout(time: 8, unit: 'MINUTES')
sidebarLinks([
[displayName: 'Gitea Repository', iconFileName: '/userContent/Yerbacon.png', urlName: 'https://gits.username404.fr/Username404-59/Yerbacon/src/branch/' + env.BRANCH_NAME]
])
}
triggers {
pollSCM('*/10 * * * *')
}
stages {
stage('Build') {
steps {
echo "Building the ${env.BRANCH_NAME} branch.."
cmakeBuild buildDir: 'cmake-build-release', buildType: 'release', cleanBuild: true, installation: 'Main',
cmakeArgs: "-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_LINKER=/usr/bin/lld"
cmake arguments: '--build ./cmake-build-release --target ybcon', installation: 'Main'
sh 'strip ./cmake-build-release/ybcon'
cpack installation: 'Main', workingDir: 'cmake-build-release'
buildTarget('arm-linux-gnueabi', 'armv4l', 'armel')
buildTarget('arm-linux-gnueabihf', 'armv7hl', 'armhf')
buildTarget('aarch64-linux-gnu', 'aarch64', 'arm64', false)
}
}
stage('Build for other platforms') {
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
cmakeBuild buildDir: 'cmake-build-release-win32', buildType: 'release', cleanBuild: true, installation: 'Main',
cmakeArgs: '-DCMAKE_C_COMPILER=/usr/bin/i686-w64-mingw32-gcc-posix -DCMAKE_CXX_COMPILER=/usr/bin/i686-w64-mingw32-c++-posix -DCMAKE_SYSTEM_PROCESSOR=i686'
cpack installation: 'Main', workingDir: 'cmake-build-release-win32'
dir('cmake-build-release-win32') { archiveArtifacts artifacts:'*.exe', fingerprint: false }
}
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
archiveArtifacts artifacts: 'cmake-build-*/*.deb, cmake-build-*/*.rpm, cmake-build-*/*.tar.gz, cmake-build-*/*.sh', fingerprint: false
}
}
}
}