diff --git a/ghaf-main-pipeline.groovy b/ghaf-main-pipeline.groovy index a01bc3b..36fd672 100644 --- a/ghaf-main-pipeline.groovy +++ b/ghaf-main-pipeline.groovy @@ -114,7 +114,7 @@ pipeline { dir(WORKDIR) { script { utils.nix_eval_jobs(targets) - target_jobs = utils.create_parallel_stages(targets) + target_jobs = utils.create_parallel_stages(targets,false,failedTargets) } } } @@ -139,15 +139,15 @@ pipeline { if (failedTargets) { formattedFailedMessage = failedTargets.collect { "- ${it.trim()}" }.join("\n") } else { - formattedFailedMessage = "None, builds were ok, maybe HW tests failed?" + formattedFailedMessage = "No failed build targets" } if (servername=="ghaf-jenkins-controller-prod") { serverchannel="ghaf-build" // prod main build failures channel echo "Slack channel:$serverchannel" line1="*FAILURE:* ${env.BUILD_URL}".stripIndent() - line2="\n*Failed Targets:*".stripIndent() - line3="\n${formattedFailedMessage}".stripIndent() - line4="\n*Commit*: <${githublink}|${env.TARGET_COMMIT}>".stripIndent() + line2="\nCommit: <${githublink}|${env.TARGET_COMMIT}>".stripIndent() + line3="\n*Failed build targets:*".stripIndent() + line4="\n${formattedFailedMessage}".stripIndent() message = """ ${line1} ${line2} diff --git a/utils.groovy b/utils.groovy index 9bd2efa..5b580dd 100644 --- a/utils.groovy +++ b/utils.groovy @@ -301,7 +301,9 @@ def nix_eval_hydrajobs(List targets) { } } -def create_parallel_stages(List targets, Boolean skip_hw_test=false) { + +// , List failedTargets = [] +def create_parallel_stages(List targets, Boolean skip_hw_test=false, List failedTargets = null) { def target_jobs = [:] targets.each { def timestampBegin = "" @@ -309,7 +311,7 @@ def create_parallel_stages(List targets, Boolean skip_hw_test=false) { def displayName = "${it.target} (${it.system})" def targetAttr = "${it.system}.${it.target}" def scsdir = "scs/${targetAttr}/scs" - + def target = "${it.target}" target_jobs[displayName] = { stage("Build ${displayName}") { def opts = "" @@ -321,8 +323,7 @@ def create_parallel_stages(List targets, Boolean skip_hw_test=false) { try { if (it.error) { error("Error in evaluation! ${it.error}") - } - + } timestampBegin = sh(script: "date +%s", returnStdout: true).trim() sh "nix build -L ${it.drvPath}\\^* ${opts}" timestampEnd = sh(script: "date +%s", returnStdout: true).trim() @@ -338,6 +339,9 @@ def create_parallel_stages(List targets, Boolean skip_hw_test=false) { } catch (Exception e) { unstable("FAILED: ${displayName}") currentBuild.result = "FAILURE" + if (failedTargets != null) { + failedTargets.add(target) + } println "Error: ${e.toString()}" } }