Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-19034] restore missing buildnumber-ID symlink when upd…
…ating permalink
  • Loading branch information
ndeloof committed Aug 23, 2013
1 parent 964d9a0 commit 2f7520c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -140,6 +140,9 @@ <h3><a name=v1.526>What's new in 1.526</a> (2013/08/05)</h3>
<li class=bug>
Ensuring <code>/log/all</code> shows only <code>INFO</code> and above messages, even if custom loggers display <code>FINE</code> or below.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18959">issue 18959</a>)
<li class=bug>
(re)create build number->id symlink if missing when updating permalink.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19034">issue 19034</a>)
<li class=rfe>
Added a new monitor that detects and fixse out-of-order builds records.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18289">issue 18289</a>)
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/jenkins/model/PeepholePermalink.java
Expand Up @@ -134,6 +134,11 @@ protected void updateCache(@Nonnull Job<?,?> job, @Nullable Run<?,?> b) {
cache.getParentFile().mkdirs();

try {
String target = String.valueOf(n);
if (b != null && !new File(job.getBuildDir(), target).exists()) {
// (re)create the build Number->Id symlink
Util.createSymlink(job.getBuildDir(),b.getId(),target,TaskListener.NULL);
}
writeSymlink(cache, String.valueOf(n));
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to update "+job+" "+getId()+" permalink for " + b, e);
Expand Down
12 changes: 12 additions & 0 deletions test/src/test/groovy/jenkins/model/PeepholePermalinkTest.groovy
Expand Up @@ -72,4 +72,16 @@ class PeepholePermalinkTest extends HudsonTestCase {
assert new File(p.rootDir,"$n/build.xml").length() == new File(b1.rootDir,"build.xml").length()
}
}

void testRebuildBuildNumberPermalinks() {
def p = createFreeStyleProject()
def b = assertBuildStatusSuccess(p.scheduleBuild2(0))
File f = new File(p.getBuildDir(), "1")
// assertTrue(Util.isSymlink(f))
f.delete()
PeepholePermalink link = p.getPermalinks().find({l -> l instanceof PeepholePermalink})
println(link)
link.updateCache(p, b)
assertTrue("build symlink hasn't been restored", f.exists())
}
}

0 comments on commit 2f7520c

Please sign in to comment.