Docker Jenkins奴隶错误的字符编码

时间:2017-04-06 08:57:26

标签: bash docker jenkins character-encoding jenkins-slave

我使用this Jenkins奴隶码头图片,它基于ubuntu:14.04

我想使用包含UTF-8字符的字符串参数。

öüóőúűáéí(匈牙利字符)等字符将被替换为question marks

在提到this票时,我试图将-e LANG=hu_HU.UTF-8bash -c "locale-gen hu_HU.UTF-8"传递给码头工人。我还将export LANG=hu_HU.UTF-8放置到Jenkins用户.bashrc,但仍然替换了字符。我也试过了en_US.UTF-8

我也尝试用Jenkins Job做同样的事情:

+ export LANG=hu_HU.UTF-8
+ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=hu_HU.UTF-8
LANGUAGE=
LC_CTYPE="hu_HU.UTF-8"
LC_NUMERIC="hu_HU.UTF-8"
LC_TIME="hu_HU.UTF-8"
LC_COLLATE="hu_HU.UTF-8"
LC_MONETARY="hu_HU.UTF-8"
LC_MESSAGES="hu_HU.UTF-8"
LC_PAPER="hu_HU.UTF-8"
LC_NAME="hu_HU.UTF-8"
LC_ADDRESS="hu_HU.UTF-8"
LC_TELEPHONE="hu_HU.UTF-8"
LC_MEASUREMENT="hu_HU.UTF-8"
LC_IDENTIFICATION="hu_HU.UTF-8"
LC_ALL=    

输出相同。

谢谢。

2 个答案:

答案 0 :(得分:1)

另一种(也许更干净)的解决方案是修改作业配置,以便将环境变量注入构建作业。

在构建环境部分中,在'属性内容'中添加环境变量。字段。

我认为这是一个更清洁的解决方案,因为本地jenkins帐户没有受到污染,而Jenkins安装则负责构建环境;当你有> 1个奴隶维持本地帐户... 从Jenkins ver1.613开始,这个解决方案是准确的

答案 1 :(得分:0)

我找到了解决方案:

bash -c "locale-gen hu_HU && locale-gen hu_HU.UTF-8 && update-locale &&  echo 'export LANG=hu_HU.UTF-8' > /jenkins/.bashrc"