@@ -78,7 +78,9 @@ function runSbt() {
7878 setScalaVersionCmd=" ++$scalaVersion !"
7979 fi
8080 tq=' """'
81- sbt ${sbtSettings[@]} \
81+ # Timeout 90 minutes
82+ timeout 5400 \
83+ sbt ${sbtSettings[@]} \
8284 " setCrossScalaVersions $scalaVersion " \
8385 " $setScalaVersionCmd -v" \
8486 " mapScalacOptions \" $appendScalacOptions \" \" $removeScalacOptions \" " \
@@ -88,20 +90,28 @@ function runSbt() {
8890 " $customCommands " \
8991 " moduleMappings" \
9092 " runBuild ${scalaVersion} ${tq}${projectConfig}${tq} $targetsString " 2>&1 | tee $logFile
93+
94+ exit_code=${PIPESTATUS[0]}
95+ if [ $exit_code -eq 124 ]; then
96+ echo " Build timeout" >> build-logs.txt
97+ echo " timeout" > $statusFile
98+ fi
99+ return $exit_code
91100}
92101
93102buildTimeouts=0
94103
95104function checkLogsForRetry() {
96105 # Retry only when given modes were not tried yet
97106 shouldRetry=false
98- # Timeout
99- if [ " $ buildTimeouts" -eq 0 ] ; then
100- if grep -q " timeout " " $statusFile " ; then
101- buildTimeouts= $(( buildTimeouts + 1 ))
107+ if grep -q " timeout " " $statusFile " ; then
108+ buildTimeouts= $(( buildTimeouts + 1 ))
109+ if [ " $buildTimeouts " -le 1 ] ; then
110+ echo " Build timeouts: $ buildTimeouts, would retry "
102111 shouldRetry=true
103112 return 0
104113 fi
114+ echo " Build timeouts: $buildTimeouts , would not try to restart"
105115 fi
106116
107117 # Failed to download artifacts
@@ -143,7 +153,7 @@ function retryBuild() {
143153 while [[ $retry -lt $maxRetries ]]; do
144154 checkLogsForRetry
145155 if [[ " $shouldRetry " == " true" ]]; then
146- retry+=1
156+ retry= $(( retry + 1 ))
147157 echo " Retrying build, retry $retry /$maxRetries , force Scala version:$forceScalaVersion , enable migration:$enableMigrationMode "
148158 runSbt && exit 0
149159 else
0 commit comments