Class BuildHistoryImporter

java.lang.Object
io.jenkins.plugins.dorametrics.collectors.BuildHistoryImporter

public final class BuildHistoryImporter extends Object
Imports builds that are already on disk, for instances where the plugin was installed after the builds ran, or where a job did not match the filters at the time.

Each build is handed to BuildRecorder.record(Run), the same entry point the listener uses, so imported builds get the same filter, commit and stage handling as builds recorded as they complete.

Only one import runs at a time. A second caller is told the import is already running rather than being allowed to double the work.

  • Method Details

    • isRunning

      public static boolean isRunning()
      True while an import is running.
    • getLastResult

      public static BuildHistoryImporter.Result getLastResult()
      A snapshot of the run in progress, or of the last one to finish, or null if none has ever run. Reading it while an import is going returns the counts so far rather than the previous run's totals.
    • importHistory

      public static BuildHistoryImporter.Result importHistory(int days)
      Imports every build newer than days days that is not already stored, on the calling thread.
      Returns:
      the counters, or null if an import was already running
    • startAsync

      public static boolean startAsync(int days)
      Starts an import on Jenkins' executor and returns at once.

      The slot is taken before this returns, not when the submitted task begins, so a caller that polls isRunning() immediately afterwards sees the import in progress rather than the counters of the previous one.

      Returns:
      false if an import was already running, in which case nothing was started
    • resolveDays

      public static int resolveDays(DoraGlobalConfiguration config)
      The import window, capped at the retention window so it cannot import rows cleanup would drop.