Record Class ScmRepo
java.lang.Object
java.lang.Record
io.jenkins.plugins.explain_error.autofix.scm.ScmRepo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbaseUrl()Returns the value of thebaseUrlrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.owner()Returns the value of theownerrecord component.static ScmRepoParses a remote URL (SSH or HTTPS) and detects the SCM type, owner, and repo name.static ScmRepoparseWithOverride(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.repoName()Returns the value of therepoNamerecord component.scmType()Returns the value of thescmTyperecord component.token()Returns the value of thetokenrecord component.toString()Overrides the record-generated toString() to redact the token so it is never accidentally printed in build logs or exception stack traces.withBaseUrl(String baseUrl) Returns a new ScmRepo with the baseUrl overridden (for enterprise instances).
-
Constructor Details
-
ScmRepo
Creates an instance of aScmReporecord class.- Parameters:
scmType- the value for thescmTyperecord componentbaseUrl- the value for thebaseUrlrecord componentowner- the value for theownerrecord componentrepoName- the value for therepoNamerecord componenttoken- the value for thetokenrecord component
-
-
Method Details
-
parse
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 viascmTypeOverride.- Parameters:
remoteUrl- the remote URL (SSH or HTTPS format) — used to extract owner/repoNametoken- 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
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
Overrides the record-generated toString() to redact the token so it is never accidentally printed in build logs or exception stack traces. -
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. -
equals
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 withObjects::equals(Object,Object). -
scmType
Returns the value of thescmTyperecord component.- Returns:
- the value of the
scmTyperecord component
-
baseUrl
Returns the value of thebaseUrlrecord component.- Returns:
- the value of the
baseUrlrecord component
-
owner
Returns the value of theownerrecord component.- Returns:
- the value of the
ownerrecord component
-
repoName
Returns the value of therepoNamerecord component.- Returns:
- the value of the
repoNamerecord component
-
token
Returns the value of thetokenrecord component.- Returns:
- the value of the
tokenrecord component
-