6
votes

Cyrillic symbols in the Console output are not displayed correctly. Jenkins is running through Tomcat / 8.5.11 on Windows 7
The Jenkins property displays:
file.encoding Cp1251
sun.jnu.encoding Cp1251
sun.stderr.encoding cp866
sun.stdout.encoding cp866

How can I set the encoding on UTF-8 in Jenkins? Encoding in autotest code is UTF-8.
It is example problem in Cyrillic text
_максимум_информации

SOLVED: I created file setenv.bat in bin folder and set JAVA_OPTS="-Dfile.encoding=UTF-8"

3

3 Answers

9
votes

According to this answer: JVM property -Dfile.encoding=UTF8 or UTF-8?

You have to add this JVM setting to your Jenkins starting script (JAVA_TOOLS_OPTIONS):

-Dfile.encoding=UTF8
3
votes

I created file setenv.bat in bin folder and set JAVA_OPTS="-Dfile.encoding=UTF-8"

0
votes

For agents gettings this Console Output:

BEFORE

Make sure agent's environment variable "LC_ALL=C.UTF-8" is set; Consle Output would return afterwards:

AFTER

Sample Pipeline:

pipeline {
   agent any
   stages {
      stage('Hello') {
         steps {
            
            echo 'Hello World'          
            
            // Latin characters always OK here.
            echo 'áéíóú' 
            
            script {
               
               // Agent requires env variable `"LC_ALL=C.UTF-8"`
               // to see 'ó' correctly through Console Output.
               sh "echo Versión ..."
               
               // Check available locales
               sh "locale -a"
            }
         }
      }
   }
}

Using Jenkins within Docker:

Jenkins Controller - Version 2.289.2; image: jenkins/jenkins:lts-jdk11

Jenkins Agent - Repo Digest ID: jenkins/ssh-agent@sha256:3292bc96