Class GitDataProvider

    • Field Detail

      • prefixDot

        protected java.lang.String prefixDot
      • abbrevLength

        protected int abbrevLength
      • dateFormat

        protected java.lang.String dateFormat
      • dateFormatTimeZone

        protected java.lang.String dateFormatTimeZone
      • evaluateOnCommit

        protected java.lang.String evaluateOnCommit
      • useBranchNameFromBuildEnvironment

        protected boolean useBranchNameFromBuildEnvironment
      • excludeProperties

        protected java.util.List<java.lang.String> excludeProperties
      • includeOnlyProperties

        protected java.util.List<java.lang.String> includeOnlyProperties
      • offline

        protected boolean offline
    • Constructor Detail

      • GitDataProvider

        public GitDataProvider​(@Nonnull
                               LoggerBridge log)
    • Method Detail

      • setPrefixDot

        public GitDataProvider setPrefixDot​(java.lang.String prefixDot)
      • setAbbrevLength

        public GitDataProvider setAbbrevLength​(int abbrevLength)
      • setDateFormat

        public GitDataProvider setDateFormat​(java.lang.String dateFormat)
      • setDateFormatTimeZone

        public GitDataProvider setDateFormatTimeZone​(java.lang.String dateFormatTimeZone)
      • setUseBranchNameFromBuildEnvironment

        public GitDataProvider setUseBranchNameFromBuildEnvironment​(boolean useBranchNameFromBuildEnvironment)
      • setExcludeProperties

        public GitDataProvider setExcludeProperties​(java.util.List<java.lang.String> excludeProperties)
      • setIncludeOnlyProperties

        public GitDataProvider setIncludeOnlyProperties​(java.util.List<java.lang.String> includeOnlyProperties)
      • determineBranchName

        protected java.lang.String determineBranchName​(@Nonnull
                                                       java.util.Map<java.lang.String,​java.lang.String> env)
                                                throws GitCommitIdExecutionException
        If running within Jenkins/Hudson, honor the branch name passed via GIT_BRANCH env var. This is necessary because Jenkins/Hudson always invoke build in a detached head state.
        Parameters:
        env - environment settings
        Returns:
        results of getBranchName() or, if in Jenkins/Hudson, value of GIT_BRANCH
        Throws:
        GitCommitIdExecutionException - the branch name could not be determined
      • getSimpleDateFormatWithTimeZone

        protected java.text.SimpleDateFormat getSimpleDateFormatWithTimeZone()
      • stripCredentialsFromOriginUrl

        protected java.lang.String stripCredentialsFromOriginUrl​(java.lang.String gitRemoteString)
                                                          throws GitCommitIdExecutionException
        If the git remote value is a URI and contains a user info component, strip the password from it if it exists. Note that this method will return an empty string if any failure occurred, while stripping the password from the credentials. This merely serves as save-guard to avoid any potential password exposure inside generated properties. This method further operates on the assumption that a valid URL schema follows the rules outlined in RFC-2396 in section "3.2.2. Server-based Naming Authority" which declares the following as valid URL schema:
          <userinfo>@<host>:<port>
          
        The "userinfo" part is declared in the same section allowing the following pattern:
            userinfo = *( unreserved | escaped | ";" | ":" | "&" | "=" | "+" | "$" | "," )
          
        The "unreserved" part is declared in section "2.3. Unreserved Characters" as the following:
            unreserved  = alphanum | mark
            mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
        
            alphanum = alpha | digit
            digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |  "8" | "9"
            alpha = lowalpha | upalpha
            lowalpha = "a" | "b" | "c" | ... | "x" | "y" | "z"
            upalpha = "A" | "B" | "C" | ... | "X" | "Y" | "Z"
          
        Parameters:
        gitRemoteString - The value of the git remote
        Returns:
        returns the gitRemoteUri with stripped password (might be used in http or https)
        Throws:
        GitCommitIdExecutionException - Exception when URI is invalid