Class GitVersion
java.lang.Object
org.jenkinsci.gradle.plugins.jpi2.GitVersion
Computes a version string from the Git repository (commit depth + abbreviated hash).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of computing the Git-derived version (version string and full hash for file output). -
Method Summary
Modifier and TypeMethodDescriptionstatic GitVersion.VersionResultcompute(Path gitRoot, String versionFormat, String versionPrefix, int abbrevLength, boolean allowDirty) Computes the version string and full hash from the given Git repository and format options.
-
Method Details
-
compute
public static GitVersion.VersionResult compute(Path gitRoot, String versionFormat, String versionPrefix, int abbrevLength, boolean allowDirty) throws IOException, InterruptedException Computes the version string and full hash from the given Git repository and format options.- Parameters:
gitRoot- root of the Git repositoryversionFormat- format string (e.g. "%d.%s" for depth.hash)versionPrefix- prefix prepended to the formatted versionabbrevLength- length of the abbreviated hashallowDirty- if false, throws when there are uncommitted changes- Returns:
- version string and full hash
- Throws:
IOException- if a git subprocess cannot be started or its output cannot be readInterruptedException- if the thread is interrupted while waiting for git to finish
-