Record Class ScmRepo

java.lang.Object
java.lang.Record
io.jenkins.plugins.explain_error.autofix.scm.ScmRepo

public record ScmRepo(ScmType scmType, String baseUrl, String owner, String repoName, String token) extends Record
  • Constructor Summary

    Constructors
    Constructor
    Description
    ScmRepo(ScmType scmType, String baseUrl, String owner, String repoName, String token)
    Creates an instance of a ScmRepo record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the baseUrl record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the owner record component.
    static ScmRepo
    parse(String remoteUrl, String token)
    Parses a remote URL (SSH or HTTPS) and detects the SCM type, owner, and repo name.
    static ScmRepo
    parseWithOverride(String remoteUrl, String token, ScmType scmType, String baseUrl)
    Parses owner/repoName from a remote URL and constructs a ScmRepo with an explicit ScmType and baseUrl.
    Returns the value of the repoName record component.
    Returns the value of the scmType record component.
    Returns the value of the token record component.
    Overrides the record-generated toString() to redact the token so it is never accidentally printed in build logs or exception stack traces.
    Returns a new ScmRepo with the baseUrl overridden (for enterprise instances).

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ScmRepo

      public ScmRepo(ScmType scmType, String baseUrl, String owner, String repoName, String token)
      Creates an instance of a ScmRepo record class.
      Parameters:
      scmType - the value for the scmType record component
      baseUrl - the value for the baseUrl record component
      owner - the value for the owner record component
      repoName - the value for the repoName record component
      token - the value for the token record component
  • Method Details

    • parse

      public static ScmRepo parse(String remoteUrl, String token)
      Parses a remote URL (SSH or HTTPS) and detects the SCM type, owner, and repo name.
      Parameters:
      remoteUrl - the remote URL (SSH or HTTPS format)
      token - the authentication token (plaintext)
      Returns:
      a populated ScmRepo
      Throws:
      IllegalArgumentException - if the URL cannot be parsed or the SCM type cannot be determined
    • parseWithOverride

      public static ScmRepo parseWithOverride(String remoteUrl, String token, ScmType scmType, String baseUrl)
      Parses owner/repoName from a remote URL and constructs a ScmRepo with an explicit ScmType and baseUrl. Used when the hostname is not a known public service (self-hosted instances) and the caller already knows the SCM type via scmTypeOverride.
      Parameters:
      remoteUrl - the remote URL (SSH or HTTPS format) — used to extract owner/repoName
      token - the authentication token (plaintext)
      scmType - the SCM type to use (bypasses host-based auto-detection)
      baseUrl - the API base URL to use
      Returns:
      a populated ScmRepo with the overridden type and baseUrl
      Throws:
      IllegalArgumentException - if the URL cannot be parsed
    • withBaseUrl

      public ScmRepo withBaseUrl(String baseUrl)
      Returns a new ScmRepo with the baseUrl overridden (for enterprise instances).
      Parameters:
      baseUrl - the new API base URL
      Returns:
      a new ScmRepo with the updated baseUrl
    • toString

      public String toString()
      Overrides the record-generated toString() to redact the token so it is never accidentally printed in build logs or exception stack traces.
      Specified by:
      toString in class Record
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • scmType

      public ScmType scmType()
      Returns the value of the scmType record component.
      Returns:
      the value of the scmType record component
    • baseUrl

      public String baseUrl()
      Returns the value of the baseUrl record component.
      Returns:
      the value of the baseUrl record component
    • owner

      public String owner()
      Returns the value of the owner record component.
      Returns:
      the value of the owner record component
    • repoName

      public String repoName()
      Returns the value of the repoName record component.
      Returns:
      the value of the repoName record component
    • token

      public String token()
      Returns the value of the token record component.
      Returns:
      the value of the token record component