From 8e3de550affce735cdefb3252b1e368aa0beb632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Samin?= Date: Mon, 2 May 2022 10:14:33 +0200 Subject: [PATCH] fix(contrib/artifactory): push build info retry (#6159) Signed-off-by: francois samin --- .../plugin-artifactory-build-info/main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/contrib/integrations/artifactory/plugin-artifactory-build-info/main.go b/contrib/integrations/artifactory/plugin-artifactory-build-info/main.go index 5b909bd57d..b471244f80 100644 --- a/contrib/integrations/artifactory/plugin-artifactory-build-info/main.go +++ b/contrib/integrations/artifactory/plugin-artifactory-build-info/main.go @@ -148,8 +148,17 @@ func (e *artifactoryBuildInfoPlugin) Run(ctx context.Context, opts *integrationp return fail("unable to compute build info: %v", err) } buildInfoRequest.Modules = modules - if _, err := artiClient.PublishBuildInfo(buildInfoRequest, artifactoryProjectKey); err != nil { - return fail("unable to push build info: %v", err) + var nbAttempts int + for { + nbAttempts++ + _, err := artiClient.PublishBuildInfo(buildInfoRequest, artifactoryProjectKey) + if err == nil { + break + } else if nbAttempts >= 3 { + return fail("unable to push build info: %v", err) + } else { + fmt.Printf("Error while pushing buildinfo %s %s. Retrying...\n", buildInfoName, version) + } } // Temporary code