Package jenkins.model

Class PeepholePermalink

All Implemented Interfaces:
Predicate<Run<?,?>>

public abstract class PeepholePermalink extends PermalinkProjectAction.Permalink implements Predicate<Run<?,?>>
Convenient base implementation for PermalinkProjectAction.Permalinks that satisfy certain properties.

For a permalink to be able to use this, it has to satisfy the following:

Given a job J, permalink is a function F that computes a build B. A peephole permalink is a subset of this function that can be deduced to the "peep-hole" function G(B)→bool:
         F(J) = { newest B | G(B)==true }
     

Intuitively speaking, a peep-hole permalink resolves to the latest build that satisfies a certain characteristics that can be determined solely by looking at the build and nothing else (most commonly its build result.)

This base class provides a file-based caching mechanism that avoids walking the long build history.

The implementation transparently tolerates G(B) that goes from true to false over time (it simply scans the history till find the new matching build.) To tolerate G(B) that goes from false to true, you need to be able to intercept whenever G(B) changes from false to true, then call resolve(Job) to check the current permalink target is up to date, then call updateCache(Job, Run) if it needs updating.

Since:
1.507
  • Field Details

  • Constructor Details

    • PeepholePermalink

      public PeepholePermalink()
  • Method Details

    • apply

      public abstract boolean apply(Run<?,?> run)
      Checks if the given build satisfies the peep-hole criteria. This is the "G(B)" as described in the class javadoc.
    • test

      public boolean test(Run<?,?> run)
      Specified by:
      test in interface Predicate<Run<?,?>>
    • getPermalinkFile

      @Deprecated protected File getPermalinkFile(Job<?,?> job)
      Deprecated.
      No longer used.
    • resolve

      public Run<?,?> resolve(Job<?,?> job)
      Resolves the permalink by using the cache if possible.
      Specified by:
      resolve in class PermalinkProjectAction.Permalink
      Returns:
      null if the target of the permalink doesn't exist.
    • updateCache

      protected void updateCache(@NonNull Job<?,?> job, @CheckForNull Run<?,?> b)
      Remembers the value 'n' in the cache for future resolve(Job).
    • initialized

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void initialized()