Skip to content

Commit 0d3add3

Browse files
authored
Merge pull request networkupstools#22 from networkupstools/issue-21
Fix reporting of quick-test phase failures and some fallout from networkupstools#18
2 parents 31ef60f + 815491c commit 0d3add3

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

vars/dynamatrixPipeline.groovy

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import hudson.model.Result;
1818
import java.text.SimpleDateFormat;
1919
import java.util.Date;
2020
import java.util.TimeZone;
21+
import java.util.concurrent.ConcurrentHashMap;
2122

2223
/*
2324
// For in-place tests as Replay pipeline:
@@ -652,8 +653,19 @@ def call(Map dynacfgBase = [:], Map dynacfgPipeline = [:]) {
652653
} // stage item: par1["Discover slow build matrix"]
653654
} // if slowBuild...
654655

656+
try {
657+
String qtxt = "Quick-test phase planned parallel stages (overall, not only dynamatrix): " + par1.values().count { it instanceof Closure }
658+
echo qtxt
659+
manager.addShortText(qtxt)
660+
} catch (Throwable ignore) {} // no-op
661+
655662
// Walk the plank
656-
parallel par1
663+
try {
664+
parallel par1
665+
} catch (Throwable t) {
666+
echo "[ERROR] Something failed in the parallel stage: ${t}"
667+
currentBuild.result = 'FAILURE'
668+
}
657669

658670
echo "Completed the 'Quick tests and prepare the bigger dynamatrix' stage"
659671
} // stage-quick tests
@@ -674,6 +686,24 @@ def call(Map dynacfgBase = [:], Map dynacfgPipeline = [:]) {
674686
echo "[Quick tests and prepare the bigger dynamatrix summary] Discovered ${Math.max(stagesBinBuild.size() - 1, 0)} 'slow build' combos to run" + (dynacfgPipeline?.failFast ? "; failFast mode is enabled: " + (dynacfgPipeline?.failFastSafe ? "dynamatrix 'safe'" : "parallel step") + " implementation" : "")
675687
echo "[Quick tests and prepare the bigger dynamatrix summary] ${currentBuild.result}"
676688
if (!(currentBuild.result in [null, 'SUCCESS'])) {
689+
// The "parallel par1" above failed...
690+
try {
691+
// Not reporting counts from our "dynamatrix" object here, it is empty up here.
692+
// The yellow badge reported until now came from another, was made (and hidden
693+
// and scrapped) by shellcheck() step => prepareDynamatrix() step.
694+
txt = "Quick-test phase: FAILED"
695+
// DO NOT remove badges - let last words be seen!
696+
// manager.removeBadges()
697+
manager.addShortText(txt)
698+
createSummary(
699+
text: txt,
700+
icon: '/images/svgs/warning.svg' // '/images/48x48/warning.png'
701+
)
702+
} catch (Throwable t) {
703+
echo "WARNING: Tried to addShortText() and createSummary(), but failed to; are the Groovy Postbuild plugin and jenkins-badge-plugin installed?"
704+
if (dynamatrixGlobalState.enableDebugTrace) echo t.toString()
705+
}
706+
677707
if (Utils.isClosure(dynacfgPipeline?.notifyHandler)) {
678708
try {
679709
// Can depend on plugins not available at this Jenkins
@@ -884,7 +914,8 @@ def call(Map dynacfgBase = [:], Map dynacfgPipeline = [:]) {
884914

885915
// Remove Jenkins-defined results; and also the
886916
// data Dynamatrix.groovy classifies; do any remain?
887-
Map<String, Integer> mapresOther = (Map<String, Integer>)(mapCountStages.clone())
917+
Map<String, Integer> mapresOther = new ConcurrentHashMap<String, Integer>()
918+
mapresOther.putAll(mapCountStages)
888919
for (String r in [
889920
'SUCCESS', 'FAILURE', 'UNSTABLE', 'ABORTED', 'NOT_BUILT',
890921
'STARTED', 'RESTARTED', 'COMPLETED', 'ABORTED_SAFE',

0 commit comments

Comments
 (0)