Closed Dahlgren closed 7 years ago
I've fixed that commit id issue but I'm unsure what you mean regarding the commits. Are you talking about the total amount of commits in the repository affecting the output? That's awfully weird.
entry.getCommitId()
string contains less than 6 characters before reaching 100 000 commits using SVN. It's an incremented integer value, not a hash like with Git or Mercurial. I.e. "12345" when there are 12345 commits. Since entry.getCommitId().substring(0, 6)
tries to fetch the first 6 characters an exception is thrown if SVN is used as the SCM and there is less than 100 000 commits (commitId "100000").
Since shortened commit id doesn't make sense for SVN the simplest solution would be to check if build SCM is SVN and if so print the entire commit id.
It's now checking just for numbers and won't shorten is that's the case. I'm not closing this until you give me the thumbs up.
It now checks for the SCM type. Didn't realise that was a thing, cheers.
https://github.com/jammehcow/jenkins-discord/blob/31cf85ffed2f2843322dab9a25321ffb161bddd3/src/main/java/nz/co/jammehcow/jenkinsdiscord/util/EmbedDescription.java#L36
The
entry.getCommitId().substring(0, 6)
required the commit id to have at least 6 characters. This is not always the case such as when using SVN as SCM in Jenkins. SVN commit id is an incremented integer value but of course is represented as a string whengetCommitId()
is called. If the repository contains too "few" commits, less than 100 000, the hook will crash when formatting the description.