From 44ffe3b7cccb6a33fd74cbd5b201fb25ca7f1fe8 Mon Sep 17 00:00:00 2001 From: Jiri Matousek Date: Fri, 20 Oct 2023 05:59:54 +0000 Subject: [PATCH] JENKINS: [FEATURE] Add support for lockable Jenkins resources --- app/ver.jenkins | 62 +++++++++-------- tests/jenkins/comp.jenkins | 14 ++-- tests/jenkins/ver_dma_medusa.jenkins | 93 +++++++++++++------------ tests/jenkins/ver_dma_medusa_xl.jenkins | 93 +++++++++++++------------ 4 files changed, 134 insertions(+), 128 deletions(-) diff --git a/app/ver.jenkins b/app/ver.jenkins index a42676ade..e70b6b53b 100644 --- a/app/ver.jenkins +++ b/app/ver.jenkins @@ -1,30 +1,32 @@ -/* - * ver.jenkins: Jenkins configuration script - * Copyright (C) 2021 CESNET z. s. p. o. - * Author(s): Radek Iša - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -// Clean previous builds -library 'liberouter' -cleanBuilds() - - -// ///////////////////////////////////////////////////////////////////////////// -// MULTI-VERIFICATION -// ///////////////////////////////////////////////////////////////////////////// -// [ 'name' , 'path_to_ver' , 'fdo_file.fdo' , 'test_pkg.sv/.vhd' , 'settings.py' ] -// ['FULL_SPEED' , 'app/uvm' , 'top_level.fdo' , 'test_pkg.vhd' , 'ver_settings.py' ],\ -def COMPONENTS_MULTIVER = [\ - ['BASE' , 'app/uvm' , 'top_level.fdo' , 'test_pkg.sv' , 'ver_settings.py' ],\ -] -// ///////////////////////////////////////////////////////////////////////////// -// Run component verifications using common script -node('preklad') { - // fetch sources from GIT - checkout scm - def common_run = load "ndk/ofm/tests/jenkins/common.jenkins" - def root_path = pwd() - common_run.commonPrekladMultiVerRun(COMPONENTS_MULTIVER, "$root_path/ndk/ofm") -} +/* + * ver.jenkins: Jenkins configuration script + * Copyright (C) 2021 CESNET z. s. p. o. + * Author(s): Radek Iša + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Clean previous builds +library 'liberouter' +cleanBuilds() + + +// ///////////////////////////////////////////////////////////////////////////// +// MULTI-VERIFICATION +// ///////////////////////////////////////////////////////////////////////////// +// [ 'name' , 'path_to_ver' , 'fdo_file.fdo' , 'test_pkg.sv/.vhd' , 'settings.py' ] +// ['FULL_SPEED' , 'app/uvm' , 'top_level.fdo' , 'test_pkg.vhd' , 'ver_settings.py' ],\ +def COMPONENTS_MULTIVER = [\ + ['BASE' , 'app/uvm' , 'top_level.fdo' , 'test_pkg.sv' , 'ver_settings.py' ],\ +] +// ///////////////////////////////////////////////////////////////////////////// +// Run component verifications using common script +node('preklad') { + lock(label:"resources-${env.NODE_NAME}", quantity: 1) { + // fetch sources from GIT + checkout scm + def common_run = load "ndk/ofm/tests/jenkins/common.jenkins" + def root_path = pwd() + common_run.commonPrekladMultiVerRun(COMPONENTS_MULTIVER, "$root_path/ndk/ofm") + } +} diff --git a/tests/jenkins/comp.jenkins b/tests/jenkins/comp.jenkins index d789b7ffa..7b344ae6f 100644 --- a/tests/jenkins/comp.jenkins +++ b/tests/jenkins/comp.jenkins @@ -36,11 +36,13 @@ def COMPONENTS_MULTIVER = [\ // Run component verifications using common script node('preklad') { - // fetch sources from GIT - checkout scm - def common_run = load "ndk/ofm/tests/jenkins/common.jenkins" - common_run.commonPrekladVerRun(COMPONENTS_VER) - def root_path = pwd() - common_run.commonPrekladMultiVerRun(COMPONENTS_MULTIVER, "$root_path/ndk/ofm") + lock(label:"resources-${env.NODE_NAME}", quantity: 1) { + // fetch sources from GIT + checkout scm + def common_run = load "ndk/ofm/tests/jenkins/common.jenkins" + common_run.commonPrekladVerRun(COMPONENTS_VER) + def root_path = pwd() + common_run.commonPrekladMultiVerRun(COMPONENTS_MULTIVER, "$root_path/ndk/ofm") + } } diff --git a/tests/jenkins/ver_dma_medusa.jenkins b/tests/jenkins/ver_dma_medusa.jenkins index 3db329a7f..707037b07 100644 --- a/tests/jenkins/ver_dma_medusa.jenkins +++ b/tests/jenkins/ver_dma_medusa.jenkins @@ -26,61 +26,62 @@ properties([ // Jenkins configuration for multiple modules node('preklad') { + lock(label:"resources-${env.NODE_NAME}", quantity: 1) { + // Clean old builds + cleanBuilds() - // Clean old builds - cleanBuilds() + // fetch sources from GIT + checkout scm + // clean artifacts possibly left by previous builds + sh "git clean -df" - // fetch sources from GIT - checkout scm - // clean artifacts possibly left by previous builds - sh "git clean -df" - - def failed = [] - // run verification of every component - withEnv(["PATH+VSIM=/usr/local/fpga/Modeltech/linux_x86_64", 'LM_LICENSE_FILE=1717@license.liberouter.org']) { - for(c in COMPONENTS) { - // parse - def name = c[0] - def path = c[1] - def fdo = c[2] - def pkg = c[3] - def settings = c[4] - def repo_root = pwd() - def multi_ver = "$repo_root/ndk/ofm/build/scripts/multi_ver/multi_ver.py" - // exec vsim - try { // try-catch is a hack to continue even after the first failed verification - timeout(time: 12, unit: 'HOURS') { - stage("$name") { - dir("$path") { - sh "python3 $multi_ver $fdo $pkg $settings" + def failed = [] + // run verification of every component + withEnv(["PATH+VSIM=/usr/local/fpga/Modeltech/linux_x86_64", 'LM_LICENSE_FILE=1717@license.liberouter.org']) { + for(c in COMPONENTS) { + // parse + def name = c[0] + def path = c[1] + def fdo = c[2] + def pkg = c[3] + def settings = c[4] + def repo_root = pwd() + def multi_ver = "$repo_root/ndk/ofm/build/scripts/multi_ver/multi_ver.py" + // exec vsim + try { // try-catch is a hack to continue even after the first failed verification + timeout(time: 12, unit: 'HOURS') { + stage("$name") { + dir("$path") { + sh "python3 $multi_ver $fdo $pkg $settings" + } } } + } catch(err) { + currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins + failed.add("$name") + } finally { // collect interesting files + archiveArtifacts "$path/transcript*" // verification log } - } catch(err) { - currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins - failed.add("$name") - } finally { // collect interesting files - archiveArtifacts "$path/transcript*" // verification log } } - } - // send out emails if failure is detected - if(currentBuild.result == "FAILURE") { - println "FAILED on components: ${failed}." - emailext \ - recipientProviders: [culprits(), developers()], - to: 'cabal@cesnet.cz', - subject: "[Jenkins] ${currentBuild.currentResult} ${env.JOB_NAME} #${currentBuild.number}", - body: """\ - The build of the repository ${env.JOB_NAME} #${currentBuild.number} ends up with status ${currentBuild.currentResult} on components: ${failed}. You can find build log in the attachments. + // send out emails if failure is detected + if(currentBuild.result == "FAILURE") { + println "FAILED on components: ${failed}." + emailext \ + recipientProviders: [culprits(), developers()], + to: 'cabal@cesnet.cz', + subject: "[Jenkins] ${currentBuild.currentResult} ${env.JOB_NAME} #${currentBuild.number}", + body: """\ + The build of the repository ${env.JOB_NAME} #${currentBuild.number} ends up with status ${currentBuild.currentResult} on components: ${failed}. You can find build log in the attachments. - For more details see ${env.BUILD_URL}. + For more details see ${env.BUILD_URL}. - Yours sincerely - Jenkins\ - """.stripIndent(), - attachLog: true, - compressLog: true + Yours sincerely + Jenkins\ + """.stripIndent(), + attachLog: true, + compressLog: true + } } } diff --git a/tests/jenkins/ver_dma_medusa_xl.jenkins b/tests/jenkins/ver_dma_medusa_xl.jenkins index cf80cb6d3..ac0435704 100644 --- a/tests/jenkins/ver_dma_medusa_xl.jenkins +++ b/tests/jenkins/ver_dma_medusa_xl.jenkins @@ -26,61 +26,62 @@ properties([ // Jenkins configuration for multiple modules node('preklad') { + lock(label:"resources-${env.NODE_NAME}", quantity: 1) { + // Clean old builds + cleanBuilds() - // Clean old builds - cleanBuilds() + // fetch sources from GIT + checkout scm + // clean artifacts possibly left by previous builds + sh "git clean -df" - // fetch sources from GIT - checkout scm - // clean artifacts possibly left by previous builds - sh "git clean -df" - - def failed = [] - // run verification of every component - withEnv(["PATH+VSIM=/usr/local/fpga/Modeltech/linux_x86_64", 'LM_LICENSE_FILE=1717@license.liberouter.org']) { - for(c in COMPONENTS) { - // parse - def name = c[0] - def path = c[1] - def fdo = c[2] - def pkg = c[3] - def settings = c[4] - def repo_root = pwd() - def multi_ver = "$repo_root/ndk/ofm/build/scripts/multi_ver/multi_ver.py" - // exec vsim - try { // try-catch is a hack to continue even after the first failed verification - timeout(time: 4, unit: 'DAYS') { - stage("$name") { - dir("$path") { - sh "python3 $multi_ver $fdo $pkg $settings" + def failed = [] + // run verification of every component + withEnv(["PATH+VSIM=/usr/local/fpga/Modeltech/linux_x86_64", 'LM_LICENSE_FILE=1717@license.liberouter.org']) { + for(c in COMPONENTS) { + // parse + def name = c[0] + def path = c[1] + def fdo = c[2] + def pkg = c[3] + def settings = c[4] + def repo_root = pwd() + def multi_ver = "$repo_root/ndk/ofm/build/scripts/multi_ver/multi_ver.py" + // exec vsim + try { // try-catch is a hack to continue even after the first failed verification + timeout(time: 4, unit: 'DAYS') { + stage("$name") { + dir("$path") { + sh "python3 $multi_ver $fdo $pkg $settings" + } } } + } catch(err) { + currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins + failed.add("$name") + } finally { // collect interesting files + archiveArtifacts "$path/transcript*" // verification log } - } catch(err) { - currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins - failed.add("$name") - } finally { // collect interesting files - archiveArtifacts "$path/transcript*" // verification log } } - } - // send out emails if failure is detected - if(currentBuild.result == "FAILURE") { - println "FAILED on components: ${failed}." - emailext \ - recipientProviders: [culprits(), developers()], - to: 'cabal@cesnet.cz', - subject: "[Jenkins] ${currentBuild.currentResult} ${env.JOB_NAME} #${currentBuild.number}", - body: """\ - The build of the repository ${env.JOB_NAME} #${currentBuild.number} ends up with status ${currentBuild.currentResult} on components: ${failed}. You can find build log in the attachments. + // send out emails if failure is detected + if(currentBuild.result == "FAILURE") { + println "FAILED on components: ${failed}." + emailext \ + recipientProviders: [culprits(), developers()], + to: 'cabal@cesnet.cz', + subject: "[Jenkins] ${currentBuild.currentResult} ${env.JOB_NAME} #${currentBuild.number}", + body: """\ + The build of the repository ${env.JOB_NAME} #${currentBuild.number} ends up with status ${currentBuild.currentResult} on components: ${failed}. You can find build log in the attachments. - For more details see ${env.BUILD_URL}. + For more details see ${env.BUILD_URL}. - Yours sincerely - Jenkins\ - """.stripIndent(), - attachLog: true, - compressLog: true + Yours sincerely + Jenkins\ + """.stripIndent(), + attachLog: true, + compressLog: true + } } }