diff --git a/src/main/groovy/com/entagen/jenkins/JenkinsApi.groovy b/src/main/groovy/com/entagen/jenkins/JenkinsApi.groovy index ff242bce..9b563b97 100644 --- a/src/main/groovy/com/entagen/jenkins/JenkinsApi.groovy +++ b/src/main/groovy/com/entagen/jenkins/JenkinsApi.groovy @@ -107,7 +107,21 @@ class JenkinsApi { body = [useincluderegex: 'on', includeRegex: "${branchView.templateJobPrefix}.*${branchView.safeBranchName}", name: viewName, json: '{"name": "' + viewName + '","useincluderegex": {"includeRegex": "' + branchView.templateJobPrefix + '.*' + branchView.safeBranchName + '"},' + VIEW_COLUMNS_JSON + '}'] println "configuring view ${viewName}" - post(buildViewPath("configSubmit", nestedWithinView, viewName), body) + int retries = 0 + while (true) { + try { + retries++ + post(buildViewPath("configSubmit", nestedWithinView, viewName), body) + return + } catch (Exception e) { + if (retries < 3) { + println "configSubmit threw exception, retrying in 1 second" + sleep(1000) + } else { + throw e + } + } + } } List getViewNames(String nestedWithinView = null) {