Skip to content
Permalink
Browse files
[FIXED JENKINS-16089]
Remember the permalink target as symlink (or simple text file) so that
looking that up doesn't cause the walk of the build history.
I think this is more in line with our general preference of making
$JENKINS_HOME useful (than trying to persist cache into a blackbox.)

Having a general purpose in-memory cache could be useful, so I'll see if
I can add that, too, in a way that allows someone to plug different
backend.
  • Loading branch information
kohsuke committed Mar 12, 2013
1 parent 1091476 commit 88feabb4296d6483bdb5c85fed489e5014161ca5
@@ -55,7 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=rfe>
Remember the lastStable/Failed/Successful/etc builds to avoid eager loading builds.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16089">issue 16089</a>)
</ul>
</div><!--=TRUNK-END=-->

@@ -1144,6 +1144,12 @@ public static String resolveSymlink(File link, TaskListener listener) throws Int
* Resolves symlink, if the given file is a symlink. Otherwise return null.
* <p>
* If the resolution fails, report an error.
*
* @return
* null if the given file is not a symlink.
* If the symlink is absolute, the returned string is an absolute path.
* If the symlink is relative, the returned string is that relative representation.
* The relative path is meant to be resolved from the location of the symlink.
*/
public static String resolveSymlink(File link) throws InterruptedException, IOException {
try { // Java 7
@@ -799,13 +799,7 @@ public RunT getFirstBuild() {
@Exported
@QuickSilver
public RunT getLastSuccessfulBuild() {
RunT r = getLastBuild();
// temporary hack till we figure out what's causing this bug
while (r != null
&& (r.isBuilding() || r.getResult() == null || r.getResult()
.isWorseThan(Result.UNSTABLE)))
r = r.getPreviousBuild();
return r;
return (RunT)Permalink.LAST_SUCCESSFUL_BUILD.resolve(this);
}

/**
@@ -23,6 +23,8 @@
*/
package hudson.model;

import jenkins.model.PeepholePermalink;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

@@ -41,6 +43,7 @@
* @see JobProperty
*/
public interface PermalinkProjectAction extends Action {

/**
* Gets the permalinks defined for this project.
*
@@ -90,90 +93,99 @@
*/
public static final List<Permalink> BUILTIN = new CopyOnWriteArrayList<Permalink>();

public static final Permalink LAST_BUILD = new Permalink() {

This comment has been minimized.

Copy link
@daniel-beck

daniel-beck Nov 17, 2015

Member

Is there a reason that this was not made a PeepholePermalink?

public String getDisplayName() {
return Messages.Permalink_LastBuild();
}

public String getId() {
return "lastBuild";
}

public Run<?,?> resolve(Job<?,?> job) {
return job.getLastBuild();
}
};
public static final Permalink LAST_STABLE_BUILD = new PeepholePermalink() {
public String getDisplayName() {
return Messages.Permalink_LastStableBuild();
}

public String getId() {
return "lastStableBuild";
}

@Override
public boolean apply(Run<?, ?> run) {
return !run.isBuilding() && run.getResult()==Result.SUCCESS;
}
};
public static final Permalink LAST_SUCCESSFUL_BUILD = new PeepholePermalink() {
public String getDisplayName() {
return Messages.Permalink_LastSuccessfulBuild();
}

public String getId() {
return "lastSuccessfulBuild";
}

@Override
public boolean apply(Run<?, ?> run) {
return !run.isBuilding() && run.getResult().isBetterOrEqualTo(Result.UNSTABLE);
}
};
public static final Permalink LAST_FAILED_BUILD = new PeepholePermalink() {
public String getDisplayName() {
return Messages.Permalink_LastFailedBuild();
}

public String getId() {
return "lastFailedBuild";
}

@Override
public boolean apply(Run<?, ?> run) {
return !run.isBuilding() && run.getResult()==Result.FAILURE;
}
};

public static final Permalink LAST_UNSTABLE_BUILD = new PeepholePermalink() {
public String getDisplayName() {
return Messages.Permalink_LastUnstableBuild();
}

public String getId() {
return "lastUnstableBuild";
}

@Override
public boolean apply(Run<?, ?> run) {
return !run.isBuilding() && run.getResult()==Result.UNSTABLE;
}
};

public static final Permalink LAST_UNSUCCESSFUL_BUILD = new PeepholePermalink() {
public String getDisplayName() {
return Messages.Permalink_LastUnsuccessfulBuild();
}

public String getId() {
return "lastUnsuccessfulBuild";
}

@Override
public boolean apply(Run<?, ?> run) {
return !run.isBuilding() && run.getResult()!=Result.SUCCESS;
}
};

static {
BUILTIN.add(new Permalink() {
public String getDisplayName() {
return Messages.Permalink_LastBuild();
}

public String getId() {
return "lastBuild";
}

public Run<?,?> resolve(Job<?,?> job) {
return job.getLastBuild();
}
});

BUILTIN.add(new Permalink() {
public String getDisplayName() {
return Messages.Permalink_LastStableBuild();
}

public String getId() {
return "lastStableBuild";
}

public Run<?,?> resolve(Job<?,?> job) {
return job.getLastStableBuild();
}
});

BUILTIN.add(new Permalink() {
public String getDisplayName() {
return Messages.Permalink_LastSuccessfulBuild();
}

public String getId() {
return "lastSuccessfulBuild";
}

public Run<?,?> resolve(Job<?,?> job) {
return job.getLastSuccessfulBuild();
}
});

BUILTIN.add(new Permalink() {
public String getDisplayName() {
return Messages.Permalink_LastFailedBuild();
}

public String getId() {
return "lastFailedBuild";
}

public Run<?,?> resolve(Job<?,?> job) {
return job.getLastFailedBuild();
}
});

BUILTIN.add(new Permalink() {
public String getDisplayName() {
return Messages.Permalink_LastUnstableBuild();
}

public String getId() {
return "lastUnstableBuild";
}

public Run<?,?> resolve(Job<?,?> job) {
return job.getLastUnstableBuild();
}
});

BUILTIN.add(new Permalink() {
public String getDisplayName() {
return Messages.Permalink_LastUnsuccessfulBuild();
}

public String getId() {
return "lastUnsuccessfulBuild";
}

public Run<?,?> resolve(Job<?,?> job) {
return job.getLastUnsuccessfulBuild();
}
});
BUILTIN.add(LAST_BUILD);
BUILTIN.add(LAST_STABLE_BUILD);
BUILTIN.add(LAST_SUCCESSFUL_BUILD);
BUILTIN.add(LAST_FAILED_BUILD);
BUILTIN.add(LAST_UNSTABLE_BUILD);
BUILTIN.add(LAST_UNSUCCESSFUL_BUILD);
}
}
}
@@ -84,6 +84,7 @@
* Default ball color for this status.
*/
public final BallColor color;
private boolean stable;

This comment has been minimized.

Copy link
@jglick

private Result(String name, BallColor color, int ordinal) {
this.name = name;

0 comments on commit 88feabb

Please sign in to comment.