Skip to content

Commit

Permalink
[JENKINS-73775] Replace call to removed CommitBuilder.setEncoding(Str…
Browse files Browse the repository at this point in the history
…ing) (#2578)

* [JENKINS-73775] Replace call to removed CommitBuilder.setEncoding(String)

JGit 7.0.0 removed the setEncoding(String) method that had been
deprecated previously.  The replacement is setEncoding(Charset).  The JGit
documentation recommends commit.setEncoding(StandardCharsets.UTF_8)

Failure was hidden by the previous setLastModified() exception because
this call happens later in the same calling sequence.

* Exclude org.eclipse.jgit from transitive inclusion

The org.eclipse.jgit jar file is already provided by the git client
plugin.  Let's not risk that a 6.9.0 copy of the library is loaded into
the same Java process that is running either JGit 6.10.0 (with git client
plugin 5.0.0) or JGit 7.0.0 with git client plugin 6.0.0)
  • Loading branch information
MarkEWaite committed Sep 16, 2024
1 parent 388654e commit 88cbc39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions blueocean-git-pipeline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
<artifactId>org.eclipse.jgit.ssh.jsch</artifactId>
<!-- TODO this is hard to manage; if needed, should be in BOM -->
<version>6.9.0.202403050737-r</version>
<exclusions>
<!-- Exclude the jgit library because it is provided by git client plugin -->
<exclusion>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- test dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public static void commit(final Repository repo, final String refName, final Str
final CommitBuilder commit = new CommitBuilder();
commit.setAuthor(author);
commit.setCommitter(author);
commit.setEncoding(Constants.CHARACTER_ENCODING);
commit.setEncoding(StandardCharsets.UTF_8);
commit.setMessage(message);
//headId can be null if the repository has no commit yet
if (headId != null) {
Expand Down

0 comments on commit 88cbc39

Please sign in to comment.