String[] ImgVariantList = ['minimal', 'default' , 'gitea' , 'nginx' , 'ddns' , 'transfersh' , 'iscsi' , 'z2mqtt' , 'nodered' , 'nodejs' , 'nextcloud' , 'mqtt' , 'hass' , 'mailbackup', 'elkarbackupALP', 'heimdall' ] pipeline { agent { label 'LXCBuilder' } parameters { booleanParam description: 'Enable muticore support for ZX compression ', name: 'ZX_Multicore' string defaultValue: '0', description: 'Set amount of core\'s ZX is allowed when compressing (use 0 for all cores)', name: 'ZX_Cores' booleanParam description: 'Only build specified variant', name: 'OneRun' string defaultValue: 'VariantName', description: 'Variant for OneBuild', name: 'OneRunVariant' booleanParam description: 'Disable of Proxy server for package repos ', name: 'DisProxy' } options { skipDefaultCheckout() buildDiscarder(logRotator(numToKeepStr: '2', artifactNumToKeepStr: '1')) } stages { stage('Prepare') { steps { // Cleanup before starting cleanWs() // Checkout the repository checkout scm // Get distrobuilder copyArtifacts filter: 'distrobuilder-BrampCustom', fingerprintArtifacts: true, flatten: true, projectName: 'LXC-ImgBuilder/DistroBuilder', selector: lastSuccessful() // Setup Env sh '''mkdir $WORKSPACE/REL mv distrobuilder-* distrobuilder bash Scripts/GetExternalResources.sh ''' //Check if Proxy is disabled script{ if (env.DisProxy == 'true') { sh '''bash Scripts/UpdateIMGBuildFile-CacheAndRepo.sh -d''' } } } } stage('Image Configs'){ steps{ script{ //Set Variantlist to one if single build if requested if (env.OneRun == 'true') { ImgVariantList = [env.OneRunVariant] } //Run build for requested variants for(ImgVariant in ImgVariantList){ env.ZX_Multicore = ZX_Multicore env.ZX_Cores = ZX_Cores env.ImgVariant = ImgVariant stage("Build ${ImgVariant}") { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { sh ''' if $ZX_Multicore; then export XZ_DEFAULTS="-T $ZX_Cores" fi sudo $WORKSPACE/distrobuilder build-lxc CT-Build/Alpine.yaml $WORKSPACE/REL/$ImgVariant/ -o image.variant=$ImgVariant sudo chown jenkins:jenkins -R $WORKSPACE/REL mv $WORKSPACE/REL/$ImgVariant/rootfs.tar.xz Alpine-$ImgVariant.tar.xz ''' } } } } } } stage('Finish') { steps { // Save generated files archiveArtifacts artifacts: '*.tar.xz', followSymlinks: false // Copy artifacts to /LXCBuild folder sh ''' mkdir -p /LXCBuild/template/cache cp -f *.tar.xz /LXCBuild/template/cache ''' // Cleaning WorkSpace when build successfully cleanWs cleanWhenAborted: false, cleanWhenFailure: false, cleanWhenNotBuilt: false, cleanWhenUnstable: false } } } }