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

Teach you to quickly build a web cluster project based on nginx

Table of contents 1. Project Environment 2. Proje...

How to deploy Confluence and jira-software in Docker

version: centos==7.2 jdk==1.8 confluence==6.15.4 ...

How to automatically back up the mysql database regularly

We all know that data is priceless. If we don’t b...

JavaScript Regular Expressions Explained

Table of contents 1. Regular expression creation ...

How to use worker_threads to create new threads in nodejs

Introduction As mentioned in the previous article...

An example of using Dapr to simplify microservices from scratch

Table of contents Preface 1. Install Docker 2. In...

WeChat applet realizes taking photos and selecting pictures from albums

This article shares the specific code for WeChat ...

Detailed explanation of JavaScript closure issues

Closures are one of the traditional features of p...

Summary of HTML formatting standards for web-based email content

1. Page requirements 1) Use standard headers and ...

Linux swap partition (detailed explanation)

Table of contents linux 1. What is SWAP 2. What d...

W3C Tutorial (8): W3C XML Schema Activities

XML Schema is an XML-based alternative to DTD. XM...

How to decrypt Linux version information

Displaying and interpreting information about you...

Vue component library ElementUI implements table loading tree data tutorial

ElementUI implements a table tree list loading tu...