Class AbstractGitSCMSource

  • All Implemented Interfaces:
    ExtensionPoint, Describable<jenkins.scm.api.SCMSource>
    Direct Known Subclasses:
    GitSCMSource

    public abstract class AbstractGitSCMSource
    extends jenkins.scm.api.SCMSource
    Base class for SCMSource implementations that produce GitSCM implementations.
    Since:
    2.0
    • Field Detail

      • DEFAULT_REMOTE_NAME

        public static final String DEFAULT_REMOTE_NAME
        The default remote name to use when configuring the ref specs to use with fetch operations.
        Since:
        3.4.0
        See Also:
        Constant Field Values
      • REF_SPEC_REMOTE_NAME_PLACEHOLDER_STR

        public static final String REF_SPEC_REMOTE_NAME_PLACEHOLDER_STR
        The placeholder to use in ref spec templates in order to correctly ensure that the ref spec remote name matches the remote name.

        The template uses @{...} as that is an illegal sequence in a remote name

        Since:
        3.4.0
        See Also:
        git source code rules on ref spec names, Constant Field Values
      • REF_SPEC_DEFAULT

        public static final String REF_SPEC_DEFAULT
        The default ref spec template.
        Since:
        3.4.0
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractGitSCMSource

        public AbstractGitSCMSource()
      • AbstractGitSCMSource

        @Deprecated
        public AbstractGitSCMSource​(String id)
        Deprecated.
    • Method Detail

      • getCredentialsId

        @CheckForNull
        public abstract String getCredentialsId()
      • getRemote

        public abstract String getRemote()
        Returns:
        Git remote URL
      • getIncludes

        @Deprecated
        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        @RestrictedSince("3.4.0")
        public String getIncludes()
        Deprecated.
        use WildcardSCMSourceFilterTrait
        Returns:
        the includes.
      • getExcludes

        @Deprecated
        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        @RestrictedSince("3.4.0")
        public String getExcludes()
        Deprecated.
        use WildcardSCMSourceFilterTrait
        Returns:
        the excludes.
      • getGitTool

        @CheckForNull
        @Deprecated
        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        @RestrictedSince("3.4.0")
        public String getGitTool()
        Deprecated.
        Gets Git tool to be used for this SCM Source.
        Returns:
        Git Tool or null if the default tool should be used.
        Since:
        2.5.1
      • getExtensions

        @NonNull
        @Deprecated
        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        @RestrictedSince("3.4.0")
        public List<GitSCMExtension> getExtensions()
        Deprecated.
        use corresponding GitSCMExtensionTrait (and if there isn't one then likely the GitSCMExtension is not appropriate to use in the context of a SCMSource)
        Gets list of extensions, which should be used with this branch source.
        Returns:
        List of Extensions to be used. May be empty
        Since:
        2.5.1
      • getTraits

        @NonNull
        public List<jenkins.scm.api.trait.SCMSourceTrait> getTraits()
        Returns the SCMSourceTrait instances for this AbstractGitSCMSource.
        Overrides:
        getTraits in class jenkins.scm.api.SCMSource
        Returns:
        the SCMSourceTrait instances
        Since:
        3.4.0
      • resolveGitTool

        @CheckForNull
        @Deprecated
        @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class)
        @RestrictedSince("3.4.0")
        protected hudson.plugins.git.GitTool resolveGitTool()
        Deprecated.
        Resolves the GitTool.
        Returns:
        the GitTool.
      • resolveGitTool

        protected hudson.plugins.git.GitTool resolveGitTool​(String gitTool,
                                                            TaskListener listener)
      • retrieve

        protected void retrieve​(@CheckForNull
                                jenkins.scm.api.SCMSourceCriteria criteria,
                                @NonNull
                                jenkins.scm.api.SCMHeadObserver observer,
                                @CheckForNull
                                jenkins.scm.api.SCMHeadEvent<?> event,
                                @NonNull
                                TaskListener listener)
                         throws IOException,
                                InterruptedException
        Specified by:
        retrieve in class jenkins.scm.api.SCMSource
        Throws:
        IOException
        InterruptedException
      • isCategoryEnabled

        protected boolean isCategoryEnabled​(@NonNull
                                            jenkins.scm.api.SCMHeadCategory category)
        Overrides:
        isCategoryEnabled in class jenkins.scm.api.SCMSource
      • getCacheEntry

        protected String getCacheEntry()
      • getCacheDir

        protected static File getCacheDir​(String cacheEntry)
      • getCacheDir

        protected static File getCacheDir​(String cacheEntry,
                                          boolean createDirectory)
      • getCacheLock

        protected static Lock getCacheLock​(String cacheEntry)
      • getCredentials

        @CheckForNull
        protected com.cloudbees.plugins.credentials.common.StandardUsernameCredentials getCredentials()
      • newBuilder

        protected GitSCMBuilder<?> newBuilder​(@NonNull
                                              jenkins.scm.api.SCMHead head,
                                              @CheckForNull
                                              jenkins.scm.api.SCMRevision revision)
        Instantiates a new GitSCMBuilder. Subclasses should override this method if they want to use a custom GitSCMBuilder or if they need to pre-decorate the builder.
        Parameters:
        head - the SCMHead.
        revision - the SCMRevision.
        Returns:
        the GitSCMBuilder
        See Also:
        for post-decoration.
      • decorate

        protected void decorate​(GitSCMBuilder<?> builder)
        Performs final decoration of the GitSCMBuilder. This method is called by build(SCMHead, SCMRevision) immediately prior to returning GitSCMBuilder.build(). Subclasses should override this method if they need to overrule builder behaviours defined by traits.
        Parameters:
        builder - the builder to decorate.
      • build

        @NonNull
        public SCM build​(@NonNull
                         jenkins.scm.api.SCMHead head,
                         @CheckForNull
                         jenkins.scm.api.SCMRevision revision)
        Specified by:
        build in class jenkins.scm.api.SCMSource
      • isExcluded

        @Deprecated
        @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class)
        @RestrictedSince("3.4.0")
        protected boolean isExcluded​(String branchName)
        Deprecated.
        use WildcardSCMSourceFilterTrait
        Returns true if the branchName isn't matched by includes or is matched by excludes.
        Parameters:
        branchName - name of branch to be tested
        Returns:
        true if branchName is excluded or is not included