Skip to content

Commit b5f894b

Browse files
committed
Matrix: drop pushed gate, surface last push error in failure
Gating imageExistsInRegistry behind pushed=true skipped the registry probe when push() threw, missing the Harbor pattern where the manifest landed but the client got EOF on the response. Always probe the registry after each push attempt; success there short-circuits the loop regardless of whether push() threw. Track the last push exception so the final reportFail message names the underlying error instead of only saying the tag was not visible.
1 parent 9678a21 commit b5f894b

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/com/mellanox/cicd/Matrix.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,30 +1192,30 @@ def buildImage(img, filename, extra_args, config, image) {
11921192
def pushAndVerify(customImage, String img, config) {
11931193
def attempts = 3
11941194
def delaySeconds = 10
1195+
def lastPushError = null
11951196

11961197
for (int i=1; i<=attempts; i++) {
1197-
def pushed = false
11981198
try {
11991199
customImage.push()
1200-
pushed = true
1200+
lastPushError = null
12011201
} catch (Exception e) {
1202+
lastPushError = e
12021203
config.logger.warn("docker push failed - ${img} - attempt ${i}/${attempts}: ${e.message}")
12031204
}
12041205

1205-
if (pushed && imageExistsInRegistry(img, config)) {
1206+
if (imageExistsInRegistry(img, config)) {
12061207
config.logger.info("Verified pushed image in registry - ${img}")
12071208
return
12081209
}
12091210

12101211
if (i < attempts) {
1211-
if (pushed) {
1212-
config.logger.warn("Pushed image is not visible in registry yet - ${img} - retry ${i}/${attempts}")
1213-
}
1212+
config.logger.warn("Pushed image is not visible in registry yet - ${img} - retry ${i}/${attempts}")
12141213
sleep(time: delaySeconds, unit: 'SECONDS')
12151214
}
12161215
}
12171216

1218-
reportFail('docker push', "Pushed image ${img} is not visible in registry after ${attempts} attempts")
1217+
def suffix = lastPushError ? " Last push error: ${lastPushError.message}" : ""
1218+
reportFail('docker push', "Pushed image ${img} is not visible in registry after ${attempts} attempts.${suffix}")
12191219
}
12201220

12211221
Boolean isEnvVarSet(var) {

0 commit comments

Comments
 (0)