Skip to content
Permalink
Browse files

JENKINS-12829: A failed update sets revision of build to 000000+

The mercurial plugin ensures that a failed clone operation throws the
corresponding exception, but that's not the case if the subsequent
update fails: no check is done of the return code of the hg update
command.

The effect is that the revision of the build is set to 000000+, which
causes a huge change log calculation in the next build, as basically
the calculated log includes all thechange setss in the history of the
repo.
  • Loading branch information...
nimeacuerdo committed Feb 19, 2012
1 parent 3de2da5 commit b1a2f8465fced379a54b6116d0fa059fc40deff7
@@ -612,11 +612,14 @@ private void clone(AbstractBuild<?,?> build, Launcher launcher, FilePath reposit
ArgumentListBuilder upArgs = new ArgumentListBuilder();
upArgs.add("update");
upArgs.add("--rev", getBranch(env));
hg.run(upArgs).pwd(repository).join();

String tip = hg.tip(repository, null);
if (tip != null) {
build.addAction(new MercurialTagAction(tip, subdir));
if (hg.run(upArgs).pwd(repository).join() != 0) {
listener.error("Failed to update " + source + " to rev " + getBranch(env));
throw new AbortException("Failed to update " + source + " to rev " + getBranch(env));
} else {
String tip = hg.tip(repository, null);
if (tip != null) {
build.addAction(new MercurialTagAction(tip, subdir));
}
}
}

@@ -32,7 +32,7 @@

public class MercurialSCMTest extends MercurialTestCase {

private File repo;
protected File repo;
protected String hgInstallation = null; // see DebugFlagTest

protected @Override
@@ -1,9 +1,13 @@
package hudson.plugins.mercurial;

import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.model.FreeStyleProject;
import hudson.model.Hudson;
import hudson.tools.ToolProperty;

import java.util.Collections;
import org.jvnet.hudson.test.Bug;

public class SharingSCMTest extends MercurialSCMTest {

@@ -16,9 +20,25 @@ void setUp() throws Exception {
Hudson.getInstance()
.getDescriptorByType(MercurialInstallation.DescriptorImpl.class)
.setInstallations(
new MercurialInstallation(SHARING_INSTALLATION, "",
new MercurialInstallation(SHARING_INSTALLATION, "",
"hg", false, true, true, Collections
.<ToolProperty<?>> emptyList()));
MercurialSCM.CACHE_LOCAL_REPOS = true;
}

@Bug(12829)
public void testNonExistingBranchesDontGenerateMercurialTagActionsInTheBuild() throws Exception {
AbstractBuild<?, ?> b;
FreeStyleProject p = createFreeStyleProject();
p.setScm(new MercurialSCM(hgInstallation, repo.getPath(), "non-existing-branch", null,
null, null, false));
hg(repo, "init");
touchAndCommit(repo, "dir1/f1");
b = p.scheduleBuild2(0).get();
for (Action action : b.getActions()) {
if (action instanceof MercurialTagAction) {
fail("There should not be any MercurialTagAction");
}
}
}
}

0 comments on commit b1a2f84

Please sign in to comment.
You can’t perform that action at this time.