From 4f8357eaf5271f60284892675e910ca0e73be748 Mon Sep 17 00:00:00 2001 From: psycho Date: Tue, 9 Feb 2021 11:16:57 +0100 Subject: [PATCH] set build status inside jenkinsfile --- Jenkinsfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index c6b3934..e4f25d3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,7 @@ statusCode = 0 mail_body = "

${JOB_NAME} - Build # ${BUILD_NUMBER} - ${currentBuild.currentResult}:

" mail_subject = "${JOB_NAME} - Build # ${BUILD_NUMBER} - ${currentBuild.currentResult}!" device_conf = '' +device = '' if(params.DEBUG) { @@ -78,6 +79,10 @@ if(params.DEVICE_CONF) { device_conf = params.DEVICE_CONF } +if(params.DEVICE) +{ + device = params.DEVICE +} def printDebug(msg) { @@ -130,6 +135,7 @@ def checkout() statusCode = sh label: 'checkout_configs', script: script, returnStatus:true if(statusCode != 0) { + currentBuild.result = 'FAILURE' throw new Exception("Error checking out configs") } script = 'git clone ' + git_link + ' ' + git_folder @@ -137,6 +143,7 @@ def checkout() statusCode = sh label: 'checkout_openwrt', script: script, returnStatus:true if(statusCode != 0) { + currentBuild.result = 'FAILURE' throw new Exception("Error checking out OWRT") } script = 'set +x; python ' + scripts_path + 'sftp_test.py -a ' + sftp_host + ' -u ' + sftp_user + ' -p ' + params.SFTP_PASSWD + ' -g ' + git_folder + ' -f ' + scripts_path + known_hosts + ' -l ' + sftp_path + '; set -x' @@ -159,6 +166,7 @@ def pre_build() stdout = sh label: 'check for config file', script: script, returnStdout: true if(!stdout.trim().equalsIgnoreCase('true')) { + currentBuild.result = 'FAILURE' throw new Exception('Error: ' + device_conf + ' not found') } script = 'cd ' + git_folder + '; patch -p1 < ../' + patch @@ -166,6 +174,7 @@ def pre_build() statusCode = sh label: 'patch_sources', script: script, returnStatus:true if(statusCode != 0) { + currentBuild.result = 'FAILURE' throw new Exception("Error patching sources") } script = 'cd ' + git_folder + '; ./scripts/feeds update -a' @@ -173,6 +182,7 @@ def pre_build() statusCode = sh label: 'feeds_update', script: script, returnStatus:true if(statusCode != 0) { + currentBuild.result = 'FAILURE' throw new Exception("Error updating feeds") } script = 'cd ' + git_folder + '; ./scripts/feeds install -a' @@ -180,6 +190,7 @@ def pre_build() statusCode = sh label: 'feeds_install', script: script, returnStatus:true if(statusCode != 0) { + currentBuild.result = 'FAILURE' throw new Exception("Error installing feeds") } } @@ -194,6 +205,7 @@ def build() sh label: 'copy_config', script: script if(statusCode != 0) { + currentBuild.result = 'FAILURE' throw new Exception("Error copying config") } script = 'cd ' + git_folder + '; make defconfig; make download; make -j$((`nproc` + 1))' @@ -208,6 +220,7 @@ def build() statusCode = sh label: 'build_single_core', script: script, returnStatus:true if(statusCode != 0) { + currentBuild.result = 'FAILURE' throw new Exception("Error building images") } } @@ -220,6 +233,9 @@ def build() statusCode = sh label: 'copy_binaries', script: script, returnStatus:true if(statusCode != 0) { + currentBuild.result = 'UNSTABLE' + post_clean = false + add2mail("Files not transferred to SFTP!") throw new Exception("Error copying binaries") } }