Class GitVersion

java.lang.Object
org.jenkinsci.gradle.plugins.jpi2.GitVersion

public final class GitVersion extends Object
Computes a version string from the Git repository (commit depth + abbreviated hash).
  • 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 repository
      versionFormat - format string (e.g. "%d.%s" for depth.hash)
      versionPrefix - prefix prepended to the formatted version
      abbrevLength - length of the abbreviated hash
      allowDirty - 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 read
      InterruptedException - if the thread is interrupted while waiting for git to finish