7

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
_максимум_информации

Adriaan
  • 17,741
  • 7
  • 42
  • 75
Denis Bolshakov
  • 305
  • 1
  • 2
  • 16
  • https://stackoverflow.com/questions/24803733/default-character-encoding-for-java-console-output try this – Praveen Kumar Sep 08 '17 at 08:47
  • 1
    Please do not add answers to the question body itself. Instead, you should add it as an answer. [Answering your own question is allowed and even encouraged](https://stackoverflow.com/help/self-answer), as you've apparently already done. – Adriaan Sep 19 '22 at 13:17

4 Answers4

9

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
Caner
  • 57,267
  • 35
  • 174
  • 180
Bruno Lavit
  • 10,184
  • 2
  • 32
  • 38
4

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


Note that the JAVA_OPTS environment variable may already be set with useful data (like JAVA_OPTS='-Djava.util.logging.config.file=<..>), so first check its current value and then append the extra -Dfile.encoding setting at the end of the existing string value.

mirekphd
  • 4,799
  • 3
  • 38
  • 59
Denis Bolshakov
  • 305
  • 1
  • 2
  • 16
1

For agents with 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

Mauricio
  • 473
  • 5
  • 11
0
  1. Go to your Jenkins installation directory and open the Jenkins XML file.
  2. Add the highlighted text(-Dfile.encoding=UTF-8) https://drive.google.com/file/d/1Ffm5ZlpBy3SGcvc6J21P62HDH36vByzI/view and save.
  3. Open Command Prompt -->Go to your Jenkins installation directory and enter the command to stop Jenkins :- jenkins.exe stop
  4. Restart jenkins by entering the command at the command prompt:- jenkins.exe restart
  5. Re-run build in jenkins and check the console output. https://prnt.sc/zoi3BmOAcKQ5