diff --git a/src/main/java/org/jenkinsci/plugins/pretestedintegration/scm/git/PretestedIntegrationAsGitPluginExt.java b/src/main/java/org/jenkinsci/plugins/pretestedintegration/scm/git/PretestedIntegrationAsGitPluginExt.java index b25f1f2e..c3605a5e 100644 --- a/src/main/java/org/jenkinsci/plugins/pretestedintegration/scm/git/PretestedIntegrationAsGitPluginExt.java +++ b/src/main/java/org/jenkinsci/plugins/pretestedintegration/scm/git/PretestedIntegrationAsGitPluginExt.java @@ -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; @@ -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 {