diff --git a/src/main/java/org/jenkinsci/plugins/pretestedintegration/scm/git/GitBridge.java b/src/main/java/org/jenkinsci/plugins/pretestedintegration/scm/git/GitBridge.java index 187cb0a6..4fa3d911 100644 --- a/src/main/java/org/jenkinsci/plugins/pretestedintegration/scm/git/GitBridge.java +++ b/src/main/java/org/jenkinsci/plugins/pretestedintegration/scm/git/GitBridge.java @@ -75,6 +75,10 @@ public static void pushToIntegrationBranchGit(Run run, TaskListener listen } } + public static void pushToBranch(TaskListener listener, GitClient client, String sourceLocalBranch, String targetRemoteBranch, String expandedRepo) throws PushFailedException { + pushToBranch(listener, client, sourceLocalBranch, targetRemoteBranch, expandedRepo, 0); + } + public static void pushToBranch(TaskListener listener, GitClient client, String sourceLocalBranch, String targetRemoteBranch, String expandedRepo, int retries) throws PushFailedException { try { LOGGER.log(Level.INFO, "Pushing changes from local branch: " + sourceLocalBranch + " to remote branch: " + targetRemoteBranch); @@ -89,7 +93,7 @@ public static void pushToBranch(TaskListener listener, GitClient client, String } catch (GitException gex) { final Pattern nonFastForward = Pattern.compile(".*[rejected].*\\(non-fast-forward\\).*", Pattern.DOTALL); //Something is wrong on the remote and it's not a fast forward issue...try again - if (gex.getMessage() != null && !nonFastForward.matcher(gex.getMessage()).matches() && retries >= 0) { + if (gex.getMessage() != null && !nonFastForward.matcher(gex.getMessage()).matches() && retries > 0) { LOGGER.log(Level.WARNING, LOG_PREFIX + "Failed to push...retrying in 5 seconds"); listener.getLogger().println(LOG_PREFIX + "Failed to push...retrying in 5 seconds"); try {