Skip to content

Commit

Permalink
[FIXED JENKINS-26519] Accept Windows text file quasi-symlinks for bui…
Browse files Browse the repository at this point in the history
…ld numbers.
  • Loading branch information
jglick committed Jan 21, 2015
1 parent 876d492 commit 056b446
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -63,6 +63,9 @@
<div id="rc" style="display:none;"><!--=BEGIN=-->
<h3><a name=v1.598>What's new in 1.598</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>
FutureImpl does not cancel its start future.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-25514">issue 25514</a>)
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/jenkins/model/RunIdMigrator.java
Expand Up @@ -199,7 +199,9 @@ private void doMigrate(File dir) {
String name = kid.getName();
try {
String link = Util.resolveSymlink(kid);
if (link == null) {
if (link == null && name.matches("\\d+") && kid.isFile()) { // legacy Windows format
link = FileUtils.readFileToString(kid);
} else if (link == null) {
continue;
}
try {
Expand Down
14 changes: 13 additions & 1 deletion core/src/test/java/jenkins/model/RunIdMigratorTest.java
Expand Up @@ -28,7 +28,6 @@
import hudson.util.StreamTaskListener;
import java.io.File;
import java.nio.charset.Charset;
import java.util.Date;
import java.util.Map;
import java.util.TimeZone;
import java.util.TreeMap;
Expand All @@ -42,6 +41,7 @@
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
import org.jvnet.hudson.test.Issue;

public class RunIdMigratorTest {

Expand Down Expand Up @@ -117,6 +117,18 @@ 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 {
Expand Down

0 comments on commit 056b446

Please sign in to comment.