How to Fix Jenkins Console Log Encoding Issue on Windows

Image for post
Image for post

If you get alien characters in console log of your job like this:

Image for post
Image for post
Newman’s Output in Jenkins Console Log

Then you have a problem with Java file encoding issue. Refer to this thread on StackOverflow, you need to add java argument -Dfile.encoding=UTF8 when running Jenkins with java command.

But in Windows, this is not straightforward when you install Jenkins as a Windows services.

Windows Service Wrapper

To run Java application as a Windows service, you cannot run it directly using java command but you need a wrapper. Jenkins uses WinSW as a services wrapper to run java and jenkins.war.

Per its documentation, you can specify Java argument in the XML config file i.e. jenkins.xml, like this:

-Dfile.encoding=UTF8
Image for post
Image for post
Editing Jenkins’ WinSW XML Config File

Now, you can see nicely character in console log. Cheers!

Image for post
Image for post
Jenkins Console Log Output with Correct Encoding

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store