Skip to content
Permalink
Browse files

[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.
(cherry picked from commit 388c4b5)

Conflicts:
	changelog.html
  • Loading branch information
jglick committed Jan 30, 2015
1 parent 22dc8ad commit 7f82ab94a4f6247abaf9f65998360be5c3136bf8
@@ -63,6 +63,9 @@
<div id="rc" style="display:none;"><!--=BEGIN=-->
<h3><a name=v1.599>What's new in 1.599</a> <!--=DATE=--></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>
Remote <code>FilePath.chmod</code> fails with <code>ClassNotFoundException: javax.servlet.ServletException</code>.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-26476">issue 26476</a>)
@@ -79,9 +82,6 @@ <h3><a name=v1.599>What's new in 1.599</a> <!--=DATE=--></h3>
</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 @@ private void doMigrate(File dir) {
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.BeforeClass;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
import org.jvnet.hudson.test.Issue;

public class RunIdMigratorTest {

@@ -129,18 +128,6 @@
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 {

0 comments on commit 7f82ab9

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