提交 388c4b5e 编写于 作者: J Jesse Glick

[FIXED JENKINS-26519] Build record migration failed on Windows using Java 6.

In this environment, Util.createSymlink and .isSymlink are implemented, but resolveSymlink is not.
上级 c886df06
......@@ -55,6 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class='major bug'>
Build format change migrator in 1.597 did not work on some Windows systems.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-26519">issue 26519</a>)
<li class=bug>
Errors in some Maven builds since 1.598.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-26601">issue 26601</a>)
......@@ -81,9 +84,6 @@ Upcoming changes</a>
</div><!--=END=-->
<h3><a name=v1.598>What's new in 1.598</a> (2015/01/25)</h3>
<ul class=image>
<li class='major bug'>
Build format change migrator in 1.597 did not work on some Windows systems.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-26519">issue 26519</a>)
<li class=bug>
FutureImpl does not cancel its start future.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-25514">issue 25514</a>)
......
......@@ -200,32 +200,22 @@ public final class RunIdMigrator {
while (it.hasNext()) {
File kid = it.next();
String name = kid.getName();
boolean numeric = false;
try {
Integer.parseInt(name);
numeric = true;
} catch (NumberFormatException x) {}
} catch (NumberFormatException x) {
LOGGER.log(FINE, "ignoring nonnumeric entry {0}", name);
continue;
}
try {
String link = Util.resolveSymlink(kid);
if (link == null && numeric && kid.isFile()) { // legacy Windows format
link = FileUtils.readFileToString(kid);
} else if (link == null) {
if (numeric) {
if (kid.isDirectory()) {
LOGGER.log(FINE, "skipping deletion of directory {0}", name);
} else {
LOGGER.log(WARNING, "need to delete non-symlink numeric directory entry {0}", name);
Util.deleteFile(kid);
}
}
if (Util.isSymlink(kid)) {
LOGGER.log(FINE, "deleting build number symlink {0} → {1}", new Object[] {name, Util.resolveSymlink(kid)});
} else if (kid.isDirectory()) {
LOGGER.log(FINE, "ignoring build directory {0}", name);
continue;
}
if (numeric) {
LOGGER.log(FINE, "deleting build number symlink {0} → {1}", new Object[] {name, link});
Util.deleteFile(kid);
} else {
LOGGER.log(FINE, "skipping other symlink {0} → {1}", new Object[] {name, link});
LOGGER.log(WARNING, "need to delete anomalous file entry {0}", name);
}
Util.deleteFile(kid);
it.remove();
} catch (Exception x) {
LOGGER.log(WARNING, "failed to process " + kid, x);
......
......@@ -42,7 +42,6 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
import org.jvnet.hudson.test.Issue;
public class RunIdMigratorTest {
......@@ -129,18 +128,6 @@ public class RunIdMigratorTest {
assertEquals("{1=→2014-01-02_03-04-05, 2014-01-02_03-04-05={build.xml='<?xml version='1.0' encoding='UTF-8'?>\n<run>\n <stuff>ok</stuff>\n <number>1</number>\n <otherstuff>ok</otherstuff>\n</run>'}}", summarize());
}
@Issue("JENKINS-26519")
@Test public void windowsQuasiLinks() throws Exception {
write("2014-01-02_03-04-05/build.xml", "<?xml version='1.0' encoding='UTF-8'?>\n<run>\n <stuff>ok</stuff>\n <number>99</number>\n <otherstuff>ok</otherstuff>\n</run>");
write("99", "2014-01-02_03-04-05");
write("lastFailedBuild", "-1");
write("lastSuccessfulBuild", "99");
assertEquals("{2014-01-02_03-04-05={build.xml='<?xml version='1.0' encoding='UTF-8'?>\n<run>\n <stuff>ok</stuff>\n <number>99</number>\n <otherstuff>ok</otherstuff>\n</run>'}, 99='2014-01-02_03-04-05', lastFailedBuild='-1', lastSuccessfulBuild='99'}", summarize());
assertTrue(migrator.migrate(dir, null));
assertEquals("{99={build.xml='<?xml version='1.0' encoding='UTF-8'?>\n<run>\n <stuff>ok</stuff>\n <id>2014-01-02_03-04-05</id>\n <timestamp>1388649845000</timestamp>\n <otherstuff>ok</otherstuff>\n</run>'}, lastFailedBuild='-1', lastSuccessfulBuild='99', legacyIds='2014-01-02_03-04-05 99\n'}", summarize());
assertEquals(99, migrator.findNumber("2014-01-02_03-04-05"));
}
// TODO test sane recovery from various error conditions
private void write(String file, String text) throws Exception {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册