Class GitHubSCMSource

java.lang.Object
hudson.model.AbstractDescribableImpl<jenkins.scm.api.SCMSource>
jenkins.scm.api.SCMSource
jenkins.plugins.git.AbstractGitSCMSource
org.jenkinsci.plugins.github_branch_source.GitHubSCMSource
All Implemented Interfaces:
ExtensionPoint, Describable<jenkins.scm.api.SCMSource>

public class GitHubSCMSource extends jenkins.plugins.git.AbstractGitSCMSource
  • Field Details

  • Constructor Details

    • GitHubSCMSource

      @DataBoundConstructor public GitHubSCMSource(String repoOwner, String repository, String repositoryUrl, boolean configuredByUrl)
      Constructor, defaults to GITHUB_URL as the end-point, and anonymous access, does not default any SCMSourceTrait behaviours.
      Parameters:
      repoOwner - the repository owner.
      repository - the repository name.
      repositoryUrl - HTML URL for the repository. If specified, takes precedence over repoOwner and repository.
      configuredByUrl - Whether to use repositoryUrl or repoOwner/repository for configuration.
      Throws:
      IllegalArgumentException - if repositoryUrl is specified but invalid.
      Since:
      2.2.0
    • GitHubSCMSource

      @Deprecated public GitHubSCMSource(String repoOwner, String repository)
      Deprecated.
      Legacy constructor.
      Parameters:
      repoOwner - the repository owner.
      repository - the repository name.
      Since:
      2.2.0
    • GitHubSCMSource

      @Deprecated public GitHubSCMSource(@CheckForNull String id, @CheckForNull String apiUri, @NonNull String checkoutCredentialsId, @CheckForNull String scanCredentialsId, @NonNull String repoOwner, @NonNull String repository)
      Deprecated.
      Legacy constructor.
      Parameters:
      id - the source id.
      apiUri - the GitHub endpoint.
      checkoutCredentialsId - the checkout credentials id or GitHubSCMSource.DescriptorImpl.SAME or GitHubSCMSource.DescriptorImpl.ANONYMOUS.
      scanCredentialsId - the scan credentials id or null.
      repoOwner - the repository owner.
      repository - the repository name.
  • Method Details

    • isConfiguredByUrl

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isConfiguredByUrl()
    • getApiUri

      @NonNull public String getApiUri()
      Returns the GitHub API end-point.
      Returns:
      the GitHub API end-point.
    • setApiUri

      @DataBoundSetter public void setApiUri(@CheckForNull String apiUri)
      Sets the GitHub API end-point.
      Parameters:
      apiUri - the GitHub API end-point or null if GITHUB_URL.
      Since:
      2.2.0
    • getCredentialsId

      @CheckForNull public String getCredentialsId()
      Gets the credentials used to access the GitHub REST API (also used as the default credentials for checking out sources.
      Specified by:
      getCredentialsId in class jenkins.plugins.git.AbstractGitSCMSource
      Returns:
      the credentials used to access the GitHub REST API or null to access anonymously
    • setCredentialsId

      @DataBoundSetter public void setCredentialsId(@CheckForNull String credentialsId)
      Sets the credentials used to access the GitHub REST API (also used as the default credentials for checking out sources.
      Parameters:
      credentialsId - the credentials used to access the GitHub REST API or null to access anonymously
      Since:
      2.2.0
    • getRepoOwner

      @Exported @NonNull public String getRepoOwner()
      Gets the repository owner.
      Returns:
      the repository owner.
    • getRepository

      @Exported @NonNull public String getRepository()
      Gets the repository name.
      Returns:
      the repository name.
    • getRepositoryUrl

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @NonNull public String getRepositoryUrl()
      Gets the repository URL as specified by the user.
      Returns:
      the repository URL as specified by the user.
    • getTraits

      public List<jenkins.scm.api.trait.SCMSourceTrait> getTraits()
      Overrides:
      getTraits in class jenkins.plugins.git.AbstractGitSCMSource
      Since:
      2.2.0
    • setTraits

      @DataBoundSetter public void setTraits(@CheckForNull List<jenkins.scm.api.trait.SCMSourceTrait> traits)
      Sets the behaviours that are applied to this GitHubSCMSource.
      Overrides:
      setTraits in class jenkins.scm.api.SCMSource
      Parameters:
      traits - the behaviours that are to be applied.
    • getEventDelaySeconds

      public static int getEventDelaySeconds()
      Returns how long to delay events received from GitHub in order to allow the API caches to sync.
      Returns:
      how long to delay events received from GitHub in order to allow the API caches to sync.
    • setEventDelaySeconds

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void setEventDelaySeconds(int eventDelaySeconds)
      Sets how long to delay events received from GitHub in order to allow the API caches to sync.
      Parameters:
      eventDelaySeconds - number of seconds to delay, will be restricted into a value within the range [0,300] inclusive
    • getCacheSize

      public static int getCacheSize()
      Returns how many megabytes of on-disk cache to maintain per GitHub API URL per credentials.
      Returns:
      how many megabytes of on-disk cache to maintain per GitHub API URL per credentials.
    • setCacheSize

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void setCacheSize(int cacheSize)
      Sets how long to delay events received from GitHub in order to allow the API caches to sync.
      Parameters:
      cacheSize - how many megabytes of on-disk cache to maintain per GitHub API URL per credentials, will be restricted into a value within the range [0,1024] inclusive.
    • getRemote

      public String getRemote()
      Specified by:
      getRemote in class jenkins.plugins.git.AbstractGitSCMSource
    • getPronoun

      public String getPronoun()
      Overrides:
      getPronoun in class jenkins.scm.api.SCMSource
    • getUriResolver

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") public RepositoryUriResolver getUriResolver()
      Returns a RepositoryUriResolver according to credentials configuration.
      Returns:
      a RepositoryUriResolver
    • getScanCredentialsId

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince("2.2.0") @Deprecated @CheckForNull public String getScanCredentialsId()
      Deprecated.
    • setScanCredentialsId

      @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") @Deprecated public void setScanCredentialsId(@CheckForNull String credentialsId)
      Deprecated.
    • getCheckoutCredentialsId

      @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") @Deprecated @CheckForNull public String getCheckoutCredentialsId()
      Deprecated.
    • setIncludes

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setIncludes(@NonNull String includes)
      Deprecated.
    • setExcludes

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setExcludes(@NonNull String excludes)
      Deprecated.
    • getBuildOriginBranch

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildOriginBranch()
      Deprecated.
    • setBuildOriginBranch

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginBranch(boolean buildOriginBranch)
      Deprecated.
    • getBuildOriginBranchWithPR

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildOriginBranchWithPR()
      Deprecated.
    • setBuildOriginBranchWithPR

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginBranchWithPR(boolean buildOriginBranchWithPR)
      Deprecated.
    • getBuildOriginPRMerge

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildOriginPRMerge()
      Deprecated.
    • setBuildOriginPRMerge

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginPRMerge(boolean buildOriginPRMerge)
      Deprecated.
    • getBuildOriginPRHead

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildOriginPRHead()
      Deprecated.
    • setBuildOriginPRHead

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildOriginPRHead(boolean buildOriginPRHead)
      Deprecated.
    • getBuildForkPRMerge

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildForkPRMerge()
      Deprecated.
    • setBuildForkPRMerge

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildForkPRMerge(boolean buildForkPRMerge)
      Deprecated.
    • getBuildForkPRHead

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") public boolean getBuildForkPRHead()
      Deprecated.
    • setBuildForkPRHead

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.2.0") @DataBoundSetter public void setBuildForkPRHead(boolean buildForkPRHead)
      Deprecated.
    • checkObserverIncludesType

      public boolean checkObserverIncludesType(@NonNull jenkins.scm.api.SCMHeadObserver observer, @NonNull Class t)
      Simple method to iterate a set of SCMHeadObserver.getIncludes() branches/tags/pr that will be possible observed and to check if at least one element is an instance of a provided class.
      Parameters:
      observer - SCMHeadObserver with an include list that are possible going to be observed.
      t - Class type to compare the set elements to.
      Returns:
      true if the observer includes list contains at least one element with the provided class type.
    • shouldRetrieve

      public boolean shouldRetrieve(@NonNull jenkins.scm.api.SCMHeadObserver observer, @CheckForNull jenkins.scm.api.SCMHeadEvent<?> event, @NonNull Class t)
      Method to verify if the conditions to retrieve information regarding a SCMHead class are met.
      Parameters:
      observer - SCMHeadObserver with the events to be observed.
      event - SCMHeadEvent with the event triggered.
      t - Class type of analyzed SCMHead.
      Returns:
      true if a retrieve should be executed form a given SCMHead Class.
    • retrieve

      protected final 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
      Overrides:
      retrieve in class jenkins.plugins.git.AbstractGitSCMSource
      Throws:
      IOException
      InterruptedException
    • retrieveRevisions

      @NonNull protected Set<String> retrieveRevisions(@NonNull TaskListener listener, Item retrieveContext) throws IOException, InterruptedException
      Overrides:
      retrieveRevisions in class jenkins.plugins.git.AbstractGitSCMSource
      Throws:
      IOException
      InterruptedException
    • retrieve

      protected jenkins.scm.api.SCMRevision retrieve(@NonNull String headName, @NonNull TaskListener listener, Item retrieveContext) throws IOException, InterruptedException
      Overrides:
      retrieve in class jenkins.plugins.git.AbstractGitSCMSource
      Throws:
      IOException
      InterruptedException
    • createProbe

      @NonNull protected jenkins.scm.api.SCMProbe createProbe(@NonNull jenkins.scm.api.SCMHead head, @CheckForNull jenkins.scm.api.SCMRevision revision) throws IOException
      Overrides:
      createProbe in class jenkins.scm.api.SCMSource
      Throws:
      IOException
    • retrieve

      @CheckForNull protected jenkins.scm.api.SCMRevision retrieve(jenkins.scm.api.SCMHead head, TaskListener listener) throws IOException, InterruptedException
      Overrides:
      retrieve in class jenkins.plugins.git.AbstractGitSCMSource
      Throws:
      IOException
      InterruptedException
    • build

      public SCM build(jenkins.scm.api.SCMHead head, jenkins.scm.api.SCMRevision revision)
      Overrides:
      build in class jenkins.plugins.git.AbstractGitSCMSource
    • getTrustedRevision

      public jenkins.scm.api.SCMRevision getTrustedRevision(jenkins.scm.api.SCMRevision revision, TaskListener listener) throws IOException, InterruptedException
      Overrides:
      getTrustedRevision in class jenkins.scm.api.SCMSource
      Throws:
      IOException
      InterruptedException
    • isCategoryEnabled

      protected boolean isCategoryEnabled(@NonNull jenkins.scm.api.SCMHeadCategory category)
      Overrides:
      isCategoryEnabled in class jenkins.plugins.git.AbstractGitSCMSource
    • retrieveActions

      @NonNull protected List<Action> retrieveActions(@NonNull jenkins.scm.api.SCMHead head, @CheckForNull jenkins.scm.api.SCMHeadEvent event, @NonNull TaskListener listener) throws IOException, InterruptedException
      Overrides:
      retrieveActions in class jenkins.plugins.git.AbstractGitSCMSource
      Throws:
      IOException
      InterruptedException
    • retrieveActions

      @NonNull protected List<Action> retrieveActions(@CheckForNull jenkins.scm.api.SCMSourceEvent event, @NonNull TaskListener listener) throws IOException
      Overrides:
      retrieveActions in class jenkins.plugins.git.AbstractGitSCMSource
      Throws:
      IOException
    • afterSave

      public void afterSave()
      Overrides:
      afterSave in class jenkins.scm.api.SCMSource