Cause of the problem
How to get Changelog (git-client plugin):
- First call the git whatchanged command to read the output byte stream (UTF-8 encoded commit Message).
- Decodes a byte stream into a string and then writes the character file to the $jenkins_home/jobs/xxx/builds/xx/changelog.xml file.
In the 2nd step, the Git-client plugin now (the latest version of 1.19.2) is decoded using the default encoding of the operating system. The default encoding for Windows is GBK (chcp command View, cp936 is GBK), and the Linux system is encoded as UTF-8 by default. If slave is windows, then the changelog byte stream, which is encoded by UTF8, will be decoded with GBK, and the changelog character obtained is garbled.
Reference:
https://github.com/jenkinsci/git-client-plugin/blob/git-client-1.19.2/src/main/java/org/jenkinsci/plugins/ Gitclient/cligitapiimpl.java
Repair:
https://github.com/jenkinsci/git-client-plugin/pull/194
Https://github.com/gennady/git-client-plugin/commit/c99c91fcf497e784204398761be5c10f438d0e55
Processing
Repair is very simple, the 2nd step decoding when the UTF-8 encoding can be specified. The problem has been fixed and a merger request has been submitted to the official. It should be fixed in a future release.
A temporary workaround is to package and install the repair version. You can use the built-in repair plugin package directly:
Https://github.com/gennady/git-client-plugin/raw/8383bd7c222b52e26b0d1b395b2eb26766f86cf7/compiled-plugin/git-client.hpi
Jenkins changelog garbled when using git SCM (Jenkins is deployed on Linux and the task is built on Windows slave)