From 88cbc39969a6e731ba7474ae3a01d539fc233be4 Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Mon, 16 Sep 2024 03:08:55 -0600 Subject: [PATCH] [JENKINS-73775] Replace call to removed CommitBuilder.setEncoding(String) (#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) --- blueocean-git-pipeline/pom.xml | 7 +++++++ .../jenkins/blueocean/blueocean_git_pipeline/GitUtils.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/blueocean-git-pipeline/pom.xml b/blueocean-git-pipeline/pom.xml index 2fa6b48b55..e2599d45c5 100644 --- a/blueocean-git-pipeline/pom.xml +++ b/blueocean-git-pipeline/pom.xml @@ -39,6 +39,13 @@ org.eclipse.jgit.ssh.jsch 6.9.0.202403050737-r + + + + org.eclipse.jgit + org.eclipse.jgit + + diff --git a/blueocean-git-pipeline/src/main/java/io/jenkins/blueocean/blueocean_git_pipeline/GitUtils.java b/blueocean-git-pipeline/src/main/java/io/jenkins/blueocean/blueocean_git_pipeline/GitUtils.java index f040c2c5d9..dbaacefb17 100644 --- a/blueocean-git-pipeline/src/main/java/io/jenkins/blueocean/blueocean_git_pipeline/GitUtils.java +++ b/blueocean-git-pipeline/src/main/java/io/jenkins/blueocean/blueocean_git_pipeline/GitUtils.java @@ -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) {