Home » Git » Jenkins – Powershell plugin – Encoding issue

Jenkins – Powershell plugin – Encoding issue

Posted by: admin November 22, 2021 Leave a comment

Questions:

I have an issue while using PowerShell Plugin on Jenkins.

First test :

When I execute this statement :

git --no-pager log [...] 

I’ve got this in the console output :

29/06/2017 13:38:04 - ééé

But, when I try to export it in a file, like this :

$log | Out-File out-default.txt

OR

$log | Out-File out-utf8.txt -Encoding UTF8

I’ve got this problem (with both files : default encoding (UTF-16LE) and UTF-8 encoding) :

29/06/2017 13:38:04 - ├®├®├®

Second test :

$log = "ééé"
$log

displays in the console output :

ǸǸǸ

For information, I’ve added -Dfile.encoding=UTF-8 in my Jenkins’ startup configuration file.

What am I missing?

Answers:

I’ve finally found a solution.

This did the trick :

git --no-pager log [...] 
[...]
$log | Out-File myFile.txt -Encoding OEM

“é” characters are successfully encoded.