Skip to content

Commit

Permalink
Revert "Update to gh-133. Use regex to parse and look for predictable…
Browse files Browse the repository at this point in the history
… non-ff commit error"

This reverts commit 73cd54f.
  • Loading branch information
MadsNielsen committed Aug 16, 2018
1 parent 9fef463 commit 4950e26
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;

/**
* The Git SCM Bridge.
Expand Down Expand Up @@ -86,19 +85,6 @@ public static void pushToBranch(TaskListener listener, GitClient client, String
LOGGER.log(Level.SEVERE, "Failed to push changes to: " + targetRemoteBranch + ".\nException:", ex);
listener.getLogger().println(GitMessages.LOG_PREFIX+ String.format("Failed to push changes to: " + targetRemoteBranch + ".\nException: %s", ex));
throw new PushFailedException(String.format("Failed to push changes to branch, message was:%n%s", ex));
} 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()) {
LOGGER.log(Level.WARNING, LOG_PREFIX + "Failed to push...retying in 5 seconds");
listener.getLogger().println(LOG_PREFIX + "Failed to push...retying in 5 seconds");
try {
Thread.sleep(5000); //Wait 5 seconds
} catch (InterruptedException e) { /* NOOP */ }
GitBridge.pushToBranch(listener, client, sourceLocalBranch, targetRemoteBranch, expandedRepo);
} else {
throw gex;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;

import static org.eclipse.jgit.lib.Constants.HEAD;
Expand Down Expand Up @@ -140,7 +138,17 @@ public Revision decorateRevisionToBuild(
gitStrategy.integrateAsGitPluginExt(scm, run, git, listener, marked, triggeredBranch, gitBridge);
//For AccumulatedCommit and in pipeline, immediately push back the merge result
if(gitStrategy instanceof AccumulatedCommitStrategy && run instanceof WorkflowRun) {
GitBridge.pushToBranch(listener, git, expandedIntegrationBranch, triggeredBranch.getName(), repoName);
try {
GitBridge.pushToBranch(listener, git, expandedIntegrationBranch, triggeredBranch.getName(), repoName);
} catch (GitException fex) {
if(fex.getMessage().contains("error: cannot lock ref")) {
//Something is wrong on the remote...try again
LOGGER.log(Level.WARNING, LOG_PREFIX + "Failed to push...retying in 5 seconds");
listener.getLogger().println(LOG_PREFIX + "Failed to push...retying in 5 seconds");
Thread.sleep(5000);
GitBridge.pushToBranch(listener, git, expandedIntegrationBranch, triggeredBranch.getName(), repoName);
}
}
}
run.addAction(new PretestTriggerCommitAction(triggeredBranch, expandedIntegrationBranch, expandedRepo, ucCredentialsId));
} else {
Expand Down

0 comments on commit 4950e26

Please sign in to comment.