Package jenkins.model

Class RunIdMigrator


@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final class RunIdMigrator extends Object
Converts legacy builds directories to the current format. There would be one instance associated with each Job, to retain ID → build# mapping. The Job.getBuildDir() is passed to every method call (rather than being cached) in case it is moved.
  • Constructor Details

    • RunIdMigrator

      public RunIdMigrator()
  • Method Details

    • created

      public void created(File dir)
      Called when a job is first created. Just saves an empty marker indicating that this job needs no migration.
      dir - as in Job.getBuildDir()
    • migrate

      public boolean migrate(File dir, @CheckForNull File jenkinsHome)
      Perform one-time migration if this has not been done already. Where previously there would be a 2014-01-02_03-04-05/build.xml specifying <number>99</number> plus a symlink 99 → 2014-01-02_03-04-05, after migration there will be just 99/build.xml specifying <id>2014-01-02_03-04-05</id> and <timestamp>…</timestamp> according to local time zone at time of migration. Newly created builds are untouched. Does not throw IOException since we make a best effort to migrate but do not consider it fatal to job loading if we cannot.
      dir - as in Job.getBuildDir()
      jenkinsHome - root directory of Jenkins (for logging only)
      true if migration was performed
    • findNumber

      public int findNumber(@NonNull String id)
      Look up a historical run by ID.
      id - a nonnumeric ID which may be a valid Run.getId()
      the corresponding Run.number, or 0 if unknown
    • delete

      public void delete(File dir, String id)
      Delete the record of a build.
      dir - as in Job.getBuildDir()
      id - a Run.getId()