When setting up Jenkins in Docker environment, the console log shows garbled Chinese characters when building tasks

When setting up Jenkins in Docker environment, the console log shows garbled Chinese characters when building tasks

1. Problem description:

In the Linux environment Centos operating system, after downloading the Jenkins image through Docker, a container was created, and the Jenkins address was accessed through the server IP+port, and the relevant configuration was performed. Then a task job was created to build and run the Java+Selenium automated test script. The current build is Success. The only drawback is that the printed log appears garbled, as shown below:

(Note: The execution machine is Jenkins itself, the same machine)

Image Description

2. Troubleshoot Jenkins settings

Jenkins system settings view the language part in the global properties

Image Description

2. Jenkins detailed information (add /systemInfo after the browser Jenkins address)

Image DescriptionImage Description

3. Code log encoding method

1. Check if the printed log is utf-8. It is confirmed that it is

Image Description

4. Linux server language information

1. Check the host language configuration and enter the command: locale -a

Image Description

2. View /.vimrc

I didn't dare to change it here because it would not affect the scope. I just found the article on CSDN.

Image Description

This is not very clear, the answer given online is:

https://blog.csdn.net/u010189459/article/details/38338735

The general meaning is that in vimrc, encoding can set these items at the same time:

set encoding=utf-8 set langmenu=zh_CN.UTF-8 language message zh_CN.UTF-8

5. Final investigation

Now that the Jenkins system settings and the host language have been checked, let's start checking the container

1. Enter the Jenkins container

docker exec -it container ID /bin/bash

View Language

insert image description here

Then enter

export LC_ALL="C.UTF-8"

Write at the end of /etc/bash.bashrc, then source /etc/bash.bashrc and find that there is no vim, so forget it.

lc_all actually assigns values ​​to all the variables above, and the effect is the same, but it doesn't hurt to try. Generally speaking, there is no such thing. Docker itself has a complete operating system and has nothing to do with the host machine.

2. Enter the Chrome browser container

set LC_ALL="C.UTF-8"

insert image description here

3. Then modify the global properties of the Jenkins system settings, change the previous LANG = zh_CN .UTF-8 to LANG = C.UTF-8. The reason is: at present, the server market is basically occupied by centos and debian. Centos relies on redhat, debian is self-sourced, centos is derived from redhat, various patches and services are more complete, centos is also used as a server. If I am not wrong, the host machine where Jenkins is located uses the debian system instead of centos, because the locale in debian supports zh_CN.UTF-8, and centos supports C.UTF-8

insert image description here

Finally, restart the Jenkins service (add /restart after the Jenkins address), then start the task and view the log of the Jenkins console!

insert image description here

Postscript: It may be that the language needs to be set in the container. It may be related to the Jenkins system setting of the global property language LANG = C.UTF-8.

Summarize

The above is the problem of garbled Chinese characters appearing in the console log when building Jenkins tasks in the Docker environment introduced by the editor. I hope it will be helpful to everyone!

You may also be interested in:
  • Docker builds Jenkins and automates the steps of packaging and deploying projects
  • Using Docker+jenkins+python3 environment to build a super detailed tutorial
  • Docker+gitlab+jenkins builds automated deployment from scratch
  • Docker builds jenkins+maven code building and deployment platform
  • Example of building a Jenkins service with Docker
  • Implementation of Jenkins automation tool using docker

<<:  Example of how to check the capacity of MySQL database table

>>:  JavaScript implements large file upload processing

Recommend

Three notification bar scrolling effects implemented with pure CSS

Preface The notification bar component is a relat...

How to receive binary file stream in Vue to realize PDF preview

Background Controller @RequestMapping("/getP...

How to run Spring Boot application in Docker

In the past few days, I have studied how to run s...

Sublime Text - Recommended method for setting browser shortcut keys

It is common to view code effects in different br...

Summary of various methods of MySQL data recovery

Table of contents 1. Introduction 2. Direct recov...

Mysql aggregate function nested use operation

Purpose: Nested use of MySQL aggregate functions ...

WeChat Mini Program Lottery Number Generator

This article shares the specific code of the WeCh...

MySQL-group-replication configuration steps (recommended)

MySQL-Group-Replication is a new feature develope...

Docker advanced method of rapid expansion

1. Command method Run the nginx service in the cr...

Detailed explanation of Nginx rewrite jump application scenarios

Application scenario 1: Domain name-based redirec...

Xftp download and installation tutorial (graphic tutorial)

If you want to transfer files between Windows and...

Detailed explanation of Alibaba Cloud security rule configuration

Two days ago, I took advantage of the Double 11 s...

Detailed installation and configuration tutorial of MySQL 5.7 under Win10

1. Unzip MySQL 5.7 2. Create a new configuration ...

HTML table tag tutorial (17): table title vertical alignment attribute VALIGN

The table caption can be placed above or below th...