Skip to content

Commit

Permalink
For gh-133. Try again when special error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNielsen committed Aug 15, 2018
1 parent aea10ca commit 22105b6
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
import org.jenkinsci.plugins.gitclient.MergeCommand;
import org.jenkinsci.plugins.pretestedintegration.IntegrationStrategy;
import org.jenkinsci.plugins.pretestedintegration.IntegrationStrategyDescriptor;
import org.jenkinsci.plugins.pretestedintegration.exceptions.EstablishingWorkspaceFailedException;
import org.jenkinsci.plugins.pretestedintegration.exceptions.IntegrationFailedException;
import org.jenkinsci.plugins.pretestedintegration.exceptions.NothingToDoException;
import org.jenkinsci.plugins.pretestedintegration.exceptions.UnsupportedConfigurationException;
import org.jenkinsci.plugins.pretestedintegration.exceptions.*;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.kohsuke.stapler.DataBoundConstructor;

Expand Down Expand Up @@ -139,10 +136,19 @@ public Revision decorateRevisionToBuild(
if(run.getActions(PretestTriggerCommitAction.class).isEmpty() ) {
GitIntegrationStrategy gitStrategy = (GitIntegrationStrategy)gitBridge.integrationStrategy;
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 10 seconds");
listener.getLogger().println(LOG_PREFIX + "Failed to push...retying in 10 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 22105b6

Please sign in to comment.