Class SCMFacade

java.lang.Object
io.jenkins.plugins.checks.github.SCMFacade

public class SCMFacade extends Object
Facade to GitHubSCMSource and GitSCM in Jenkins. Used for finding a supported SCM of a job.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Optional<com.cloudbees.plugins.credentials.common.StandardUsernameCredentials>
    findGitHubAppCredentials(Job<?,?> job, String credentialsId)
    Find GitHubAppCredentials with the credentialsId used by the job.
    Optional<org.jenkinsci.plugins.github_branch_source.GitHubSCMSource>
    Find GitHubSCMSource (or GitHub repository) used by the job.
    Optional<hudson.plugins.git.GitSCM>
    findGitSCM(Job<?,?> job)
    Finds the GitSCM used by the job.
    Optional<hudson.plugins.git.GitSCM>
    findGitSCM(Run<?,?> run)
    Finds the GitSCM used by the run.
    Optional<jenkins.plugins.git.GitSCMSource>
    Find GitSCMSource used by the job.
    findHash(jenkins.scm.api.SCMRevision revision)
    Find the hash value in revision.
    Optional<jenkins.scm.api.SCMHead>
    findHead(Job<?,?> job)
    Find SCMHead (or branch) used by the job.
    Optional<jenkins.scm.api.SCMRevision>
    findRevision(jenkins.scm.api.SCMSource source, jenkins.scm.api.SCMHead head)
    Fetch the current SCMRevision used by the head of the source.
    Optional<jenkins.scm.api.SCMRevision>
    findRevision(org.jenkinsci.plugins.github_branch_source.GitHubSCMSource source, Run<?,?> run)
    Find the current SCMRevision of the source and run locally through SCMRevisionAction.
    jenkins.scm.api.SCMSource
    findSCMSource(Job<?,?> job)
    Find GitHubSCMSource (or GitHub repository) used by the job.
    getScm(Job<?,?> job)
    Returns the SCM in a given job.
    getScm(Run<?,?> run)
    Returns the SCM in a given build.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SCMFacade

      public SCMFacade()
  • Method Details

    • findSCMSource

      @CheckForNull public jenkins.scm.api.SCMSource findSCMSource(Job<?,?> job)
      Find GitHubSCMSource (or GitHub repository) used by the job.
      Parameters:
      job - the Jenkins project
      Returns:
      the found GitHub SCM source used or empty
    • findGitHubSCMSource

      public Optional<org.jenkinsci.plugins.github_branch_source.GitHubSCMSource> findGitHubSCMSource(Job<?,?> job)
      Find GitHubSCMSource (or GitHub repository) used by the job.
      Parameters:
      job - the Jenkins project
      Returns:
      the found GitHub SCM source used or empty
    • findGitSCMSource

      public Optional<jenkins.plugins.git.GitSCMSource> findGitSCMSource(Job<?,?> job)
      Find GitSCMSource used by the job.
      Parameters:
      job - the Jenkins project
      Returns:
      the found Git SCN source or empty
    • findGitSCM

      public Optional<hudson.plugins.git.GitSCM> findGitSCM(Run<?,?> run)
      Finds the GitSCM used by the run.
      Parameters:
      run - the run to get the SCM from
      Returns:
      the found GitSCM or empty
    • findGitSCM

      public Optional<hudson.plugins.git.GitSCM> findGitSCM(Job<?,?> job)
      Finds the GitSCM used by the job.
      Parameters:
      job - the job to get the SCM from
      Returns:
      the found GitSCM or empty
    • findGitHubAppCredentials

      public Optional<com.cloudbees.plugins.credentials.common.StandardUsernameCredentials> findGitHubAppCredentials(Job<?,?> job, String credentialsId)
      Find GitHubAppCredentials with the credentialsId used by the job.
      Parameters:
      job - the Jenkins project
      credentialsId - the id of the target credentials
      Returns:
      the found GitHub App credentials or empty
    • findHead

      public Optional<jenkins.scm.api.SCMHead> findHead(Job<?,?> job)
      Find SCMHead (or branch) used by the job.
      Parameters:
      job - the Jenkins project
      Returns:
      the found SCM head or empty
    • findRevision

      public Optional<jenkins.scm.api.SCMRevision> findRevision(jenkins.scm.api.SCMSource source, jenkins.scm.api.SCMHead head)
      Fetch the current SCMRevision used by the head of the source.
      Parameters:
      source - the GitHub repository
      head - the branch
      Returns:
      the fetched revision or empty
    • findRevision

      public Optional<jenkins.scm.api.SCMRevision> findRevision(org.jenkinsci.plugins.github_branch_source.GitHubSCMSource source, Run<?,?> run)
      Find the current SCMRevision of the source and run locally through SCMRevisionAction.
      Parameters:
      source - the GitHub repository
      run - the Jenkins run
      Returns:
      the found revision or empty
    • findHash

      public Optional<String> findHash(jenkins.scm.api.SCMRevision revision)
      Find the hash value in revision.
      Parameters:
      revision - the revision for a build
      Returns:
      the found hash or empty
    • getScm

      public SCM getScm(Run<?,?> run)
      Returns the SCM in a given build. If no SCM can be determined, then a NullSCM instance will be returned.
      Parameters:
      run - the build to get the SCM from
      Returns:
      the SCM
    • getScm

      public SCM getScm(Job<?,?> job)
      Returns the SCM in a given job. If no SCM can be determined, then a NullSCM instance will be returned.
      Parameters:
      job - the job to get the SCM from
      Returns:
      the SCM