Class SCMHeadMigration<S extends SCMSource,H extends SCMHead,R extends SCMRevision>

java.lang.Object
jenkins.scm.api.SCMHeadMigration<S,H,R>
All Implemented Interfaces:
ExtensionPoint

public abstract class SCMHeadMigration<S extends SCMSource,H extends SCMHead,R extends SCMRevision> extends Object implements ExtensionPoint
If a SCMSource plugin needs to migrate the implementation classes for SCMHead this extension point allows the plugin to register type migrations. For speed of migration implementations should just jump directly to the final end-point and not expect recursive chain walking.
Since:
2.0.2
  • Constructor Details

    • SCMHeadMigration

      protected SCMHeadMigration(Class<S> sourceClass, Class<H> headClass, Class<R> revisionClass)
      Constructor.
      Parameters:
      sourceClass - the SCMSource that the migration applies to.
      headClass - the SCMHead that the migration applies to.
      revisionClass - the SCMRevision that the migration applies to.
  • Method Details

    • getSCMSourceClass

      public final Class<S> getSCMSourceClass()
      Gets the SCMSource that the migration applies to.
      Returns:
      the SCMSource that the migration applies to.
    • getSCMHeadClass

      public final Class<H> getSCMHeadClass()
      Gets the SCMHead that the migration applies to.
      Returns:
      the SCMHead that the migration applies to.
    • getSCMRevisionClass

      public final Class<R> getSCMRevisionClass()
      Gets the SCMRevision that the migration applies to.
      Returns:
      the SCMRevision that the migration applies to.
    • migrate

      @CheckForNull public abstract SCMHead migrate(@NonNull S source, @NonNull H head)
      Perform a migration.

      Note: if you migrate a SCMHead then most likely you will also want to migrate the SCMRevision instances associated with that SCMHead - at the very least to update SCMRevision.getHead().

      Parameters:
      source - the source instance.
      head - the candidate head.
      Returns:
      the migrated head or null if the migration was not appropriate.
    • migrate

      @CheckForNull public SCMRevision migrate(@NonNull S source, @NonNull R revision)
      Perform a migration.
      Parameters:
      source - the source instance.
      revision - the candidate revision.
      Returns:
      the migrated revision or null if the migration was not appropriate.
    • readResolveSCMHead

      @NonNull public static SCMHead readResolveSCMHead(@NonNull SCMSource source, @NonNull SCMHead head)
      Perform a migration.
      Parameters:
      source - the source instance.
      head - the candidate head.
      Returns:
      the migrated head or the original head.
    • readResolveSCMRevision

      @CheckForNull public static SCMRevision readResolveSCMRevision(@NonNull SCMSource source, @CheckForNull SCMRevision revision)
      Perform a migration.
      Parameters:
      source - the source instance.
      revision - the candidate revision.
      Returns:
      the migrated revision or the original revision.