diff --git a/Jenkinsfile b/Jenkinsfile index 09486e3..76f283f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,386 +3,160 @@ pipeline { parameters { booleanParam(defaultValue: true, description: 'Deploy this build', name: 'deploy_build') - choice(choices: ['none', 'x86_debug', 'x86_release', 'x86_stable', 'amd64_debug', 'amd64_release', 'amd64_stable', 'arm32v7_debug', 'arm32v7_release', 'arm32v7_stable'], description: 'Which target do you want to build?', name: 'target') + booleanParam(name: 'build_amd64', defaultValue: false, description: 'Build for amd64') + booleanParam(name: 'build_arm32v7', defaultValue: false, description: 'Build for arm32v7') + booleanParam(name: 'build_x86', defaultValue: false, description: 'Build for x86') + choice(choices: ['none', 'debug', 'optimized', 'stable'], description: 'What kind of build do you want to run?', name: 'build_type') } - environment { - //CMake specific flags - CMAKE_OPTIONS = '' - CMAKE_MAKE_OPTIONS = '-j32' + environment { + //CMake specific flags + CMAKE_OPTIONS = '' + CMAKE_MAKE_OPTIONS = '-j32' - //Make specific flags - MAKE_OPTIONS = '-j32' - - JENKINS_BUILD_TARGET="${params.target}" - } - - stages { - /* build all amd64 stuff */ - stage ('build::amd64') { - agent { - label 'linux && amd64 && teaspeak' - } - when { - expression { params.target == "amd64_debug" || params.target == "amd64_release" || params.target == "amd64_stable" } - } - - environment { - build_os_type="linux" - build_os_arch="amd64" - } - - stages { - stage ('build::amd64::libraries') { - environment { - CMAKE_BUILD_TYPE="RelWithDebInfo" /* we build out libraries every time in release mode! (Performance improve) */ - } + //Make specific flags + MAKE_OPTIONS = '-j32' + + JENKINS_BUILD_TARGET="${params.target}" + } + + stages { + /* build all amd64 stuff */ + stage ('build::amd64') { + agent { + label 'linux && amd64 && teaspeak' + } - steps { - sh './attach_modules.sh' - sh 'cd libraries; ./build.sh' - } - } - - - stage ('build::amd64::debug') { - when { - expression { params.target == "amd64_debug" } - } - - stages { - stage ('build::amd64::debug::build') { - environment { - TEASPEAK_BUILD_TYPE="Debug" - CMAKE_BUILD_TYPE="Debug" - - TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=1 -DBUILD_TYPE_NAME='beta'" - } + when { + expression { params.build_amd64 } + } + + environment { + build_os_type="linux" + build_os_arch="amd64" + } + + stages { + stage ('build::amd64::libraries') { + environment { + CMAKE_BUILD_TYPE="RelWithDebInfo" /* we build out libraries every time in release mode! (Performance improve) */ + } - steps { - sh './build_teaspeak.sh' - } - } + steps { + sh './attach_modules.sh' + sh 'cd libraries; ./build.sh' + } + } + + + stage ('build::amd64::build') { + steps { + sh './build_teaspeak.sh' + } + } - stage ('build::amd64::debug::deploy') { - when { - expression { params.deploy_build } - } + stage ('build::amd64::deploy') { + when { + expression { params.deploy_build } + } - steps { - sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/amd64_debug' - } - } - } - } - - stage ('build::amd64::release') { - when { - expression { params.target == "amd64_release" } - } - - stages { - stage ('build::amd64::release::build') { - environment { - TEASPEAK_BUILD_TYPE="Release" - CMAKE_BUILD_TYPE="RelWithDebInfo" - - TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=1 -DBUILD_TYPE_NAME='beta'" - } + steps { + sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/amd64_${params.build_type}' + } + } + } + } - steps { - sh './build_teaspeak.sh' - } - } + /* build all x86 stuff */ + stage ('build::x86') { + agent { + label 'linux && x86 && teaspeak' + } - stage ('build::amd64::release::deploy') { - when { - expression { params.deploy_build } - } + when { + expression { params.build_x86 } + } + + environment { + build_os_type="linux" + build_os_arch="x86" + } + + stages { + stage ('build::x86::libraries') { + environment { + CMAKE_BUILD_TYPE="RelWithDebInfo" /* we build out libraries every time in release mode! (Performance improve) */ + } - steps { - sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/amd64_optimized' - } - } - } - } - - stage ('build::amd64::stable') { - when { - expression { params.target == "amd64_stable" } - } - - stages { - stage ('build::amd64::stable::build') { - environment { - TEASPEAK_BUILD_TYPE="Release" - CMAKE_BUILD_TYPE="RelWithDebInfo" - - TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=0 -DBUILD_TYPE_NAME=''" - } + steps { + sh './attach_modules.sh' + sh 'cd libraries; ./build.sh' + } + } + + + stage ('build::x86::build') { + steps { + sh './build_teaspeak.sh' + } + } - steps { - sh './build_teaspeak.sh' - } - } + stage ('build::x86::deploy') { + when { + expression { params.deploy_build } + } - stage ('build::amd64::stable::deploy') { - when { - expression { params.deploy_build } - } + steps { + sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/x86_${params.build_type}' + } + } + } + } - steps { - sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/amd64_stable' - } - } - } - } - } - } - - /* build all x86 stuff */ - stage ('build::x86') { - agent { - label 'linux && x86 && teaspeak' - } - when { - expression { params.target == "x86_debug" || params.target == "x86_release" || params.target == "x86_stable" } - } - - environment { - build_os_type="linux" - build_os_arch="x86" - } - - stages { - stage ('build::x86::libraries') { - environment { - CMAKE_BUILD_TYPE="RelWithDebInfo" /* we build out libraries every time in release mode! (Performance improve) */ - BUILD_ARCH_TARGET="x86" - } + /* build all arm32v7 stuff */ + stage ('build::arm32v7') { + agent { + label 'linux && arm32v7 && teaspeak' + } - steps { - sh './attach_modules.sh' - sh 'cd libraries; ./build.sh' - } - } - - - stage ('build::x86::debug') { - when { - expression { params.target == "x86_debug" } - } - - stages { - stage ('build::x86::debug::build') { - environment { - TEASPEAK_BUILD_TYPE="Debug" - CMAKE_BUILD_TYPE="Debug" - - TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=1 -DBUILD_TYPE_NAME='beta'" - } + when { + expression { params.build_arm32v7 } + } + + environment { + build_os_type="linux" + build_os_arch="arm32v7" + } + + stages { + stage ('build::x86::libraries') { + environment { + CMAKE_BUILD_TYPE="RelWithDebInfo" /* we build out libraries every time in release mode! (Performance improve) */ + } - steps { - sh './build_teaspeak.sh' - } - } + steps { + sh './attach_modules.sh' + sh 'cd libraries; ./build.sh' + } + } + + + stage ('build::arm32v7::build') { + steps { + sh './build_teaspeak.sh' + } + } - stage ('build::x86::debug::deploy') { - when { - expression { params.deploy_build } - } + stage ('build::arm32v7::deploy') { + when { + expression { params.deploy_build } + } - steps { - sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/x86_debug' - } - } - } - } - - stage ('build::x86::release') { - when { - expression { params.target == "x86_release" } - } - - stages { - stage ('build::x86::release::build') { - environment { - TEASPEAK_BUILD_TYPE="Release" - CMAKE_BUILD_TYPE="RelWithDebInfo" - - TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=1 -DBUILD_TYPE_NAME='beta'" - } - - steps { - sh './build_teaspeak.sh' - } - } - - stage ('build::x86::release::deploy') { - when { - expression { params.deploy_build } - } - - steps { - sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/x86_optimized' - } - } - } - } - - stage ('build::x86::stable') { - when { - expression { params.target == "x86_stable" } - } - - stages { - stage ('build::x86::stable::build') { - environment { - TEASPEAK_BUILD_TYPE="Release" - CMAKE_BUILD_TYPE="RelWithDebInfo" - - TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=0 -DBUILD_TYPE_NAME=''" - } - - steps { - sh './build_teaspeak.sh' - } - } - - stage ('build::x86::stable::deploy') { - when { - expression { params.deploy_build } - } - - steps { - sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/x86_stable' - } - } - } - } - } - } - - /* build all arm32v7 stuff */ - stage ('build::arm32v7') { - agent { - label 'linux && arm32v7 && teaspeak' - } - when { - expression { params.target == "arm32v7_debug" || params.target == "arm32v7_release" || params.target == "arm32v7_stable" } - } - - environment { - build_os_type="linux" - build_os_arch="arm32v7" - } - - stages { - stage ('build::arm32v7::libraries') { - environment { - CMAKE_BUILD_TYPE="RelWithDebInfo" /* we build out libraries every time in release mode! (Performance improve) */ - } - - steps { - sh './attach_modules.sh' - sh 'cd libraries; ./build.sh' - } - } - - - stage ('build::arm32v7::debug') { - when { - expression { params.target == "arm32v7_debug" } - } - - stages { - stage ('build::amd64::debug::build') { - environment { - TEASPEAK_BUILD_TYPE="Debug" - CMAKE_BUILD_TYPE="Debug" - - TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=1 -DBUILD_TYPE_NAME='beta'" - } - - steps { - sh './build_teaspeak.sh' - } - } - - stage ('build::amd64::debug::deploy') { - when { - expression { params.deploy_build } - } - - steps { - sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/arm32v7_debug' - } - } - } - } - - stage ('build::arm32v7::release') { - when { - expression { params.target == "arm32v7_release" } - } - - stages { - stage ('build::arm32v7::release::build') { - environment { - TEASPEAK_BUILD_TYPE="Release" - CMAKE_BUILD_TYPE="RelWithDebInfo" - - TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=1 -DBUILD_TYPE_NAME='beta'" - } - - steps { - sh './build_teaspeak.sh' - } - } - - stage ('build::arm32v7::release::deploy') { - when { - expression { params.deploy_build } - } - - steps { - sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/arm32v7_optimized' - } - } - } - } - - stage ('build::arm32v7::stable') { - when { - expression { params.target == "arm32v7_stable" } - } - - stages { - stage ('build::arm32v7::stable::build') { - environment { - TEASPEAK_BUILD_TYPE="Release" - CMAKE_BUILD_TYPE="RelWithDebInfo" - - TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=0 -DBUILD_TYPE_NAME=''" - } - - steps { - sh './build_teaspeak.sh' - } - } - - stage ('build::arm32v7::stable::deploy') { - when { - expression { params.deploy_build } - } - - steps { - sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/arm32v7_stable' - } - } - } - } - } - } - } + steps { + sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/arm32v7_${params.build_type}' + } + } + } + } + } } diff --git a/build_teaspeak.sh b/build_teaspeak.sh index 80df3ce..670f9d8 100755 --- a/build_teaspeak.sh +++ b/build_teaspeak.sh @@ -1,6 +1,33 @@ #!/bin/bash _build_helper_dir="$(pwd)/build-helpers" +_build_type="Debug" +if [[ -n "${params.build_type}" ]]; then + echo "This is an automated jenkins build. Initializing variables." + + if [[ "${params.build_type}" == "debug" ]]; then + echo "Initializing debug session." + export _build_type="Debug" + # shellcheck disable=SC2089 + export TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=1 -DBUILD_TYPE_NAME=\"beta\"" + elif [[ "${params.build_type}" == "optimized" ]]; then + echo "Initializing optimized session." + export _build_type="RelWithDebInfo" + # shellcheck disable=SC2089 + export TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=1 -DBUILD_TYPE_NAME=\"beta\"" + elif [[ "${params.build_type}" == "stable" ]]; then + echo "Initializing stable session." + export _build_type="RelWithDebInfo" + # shellcheck disable=SC2089 + export TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=0 -DBUILD_TYPE_NAME=\"\"" + + else + echo "Unknown target build type: ${params.build_type}" + exit 1 + fi +fi + + # shellcheck disable=SC2154 if [[ "$no_web" == "1" ]]; then echo "Disabling web support" @@ -10,13 +37,14 @@ else fi cd TeaSpeak || exit 1 -if [ -d build ]; then +if [[ -d build ]]; then rm -r build fi -mkdir build && cd build || exit 1 +mkdir build || exit 1 +cd build || exit 1 -echo "Build type: ${TEASPEAK_BUILD_TYPE}" -cmake .. -DCMAKE_BUILD_TYPE="${TEASPEAK_BUILD_TYPE}" -DCMAKE_CXX_FLAGS=" ${CXX_FLAGS}" -DBUILD_INCLUDE_FILE="$_build_helper_dir"/cmake/config/tearoot-server.cmake -DCMAKE_MODULE_PATH="$_build_helper_dir"/cmake/ -DDISABLE_QT=1 -DDISABLE_CUSTOM_OUTPUT=ON -DDISABLE_QT=ON -DCOMPILE_WEB_CLIENT="$_web_flag" $TEASPEAK_DEPLOY_TYPE_SPECIFIER +echo "Build type: $_build_type" +cmake .. -DCMAKE_BUILD_TYPE="$_build_type" -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" -DBUILD_INCLUDE_FILE="$_build_helper_dir"/cmake/config/tearoot-server.cmake -DCMAKE_MODULE_PATH="$_build_helper_dir"/cmake/ -DDISABLE_QT=1 -DDISABLE_CUSTOM_OUTPUT=ON -DDISABLE_QT=ON -DCOMPILE_WEB_CLIENT="$_web_flag" $TEASPEAK_DEPLOY_TYPE_SPECIFIER _code=$? if [[ $_code -ne 0 ]]; then echo "Failed to run CMAKE project"