您如何在Jenkins中设置默认编码? [英] How do you set the default encoding in Jenkins?

查看:317
本文介绍了您如何在Jenkins中设置默认编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个输出非ASCII字符的python脚本. 它可以从命令行正常运行(具有LANG en_US.UTF-8),但是一旦我尝试在Jenkins中运行(从同一shell启动),它就无法通过ascii终端的典型方式运行:

I have a python script that outputs non-ascii characters. It works fine from the command line (which has LANG en_US.UTF-8), but once I try to run it in Jenkins (launched from the same shell), it fails in the typical manner of an ascii terminal:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 37: ordinal not in range(128)

我已经尝试过在执行外壳"构建步骤中执行脚本调用,如下所示:

I've tried preceeding the script call in the "Execute shell" build step like so:

export LANG=en_US.UTF-8

但是,似乎忽略了这一点.将以下内容放入我的python脚本中:

However, it seems to ignore that. Putting the following in my python script:

print "Encoding = %s" % sys.getdefaultencoding()

不管我做什么,都给我:

Gives me this, no matter what I do:

Encoding = ascii

那么有什么可以让我强迫詹金斯使用UTF-8吗?

So is there something that will allow me to force Jenkins to use UTF-8?

推荐答案

没关系,发现了如何做:

Never mind, found out how to do it:

export PYTHONIOENCODING=UTF-8

这篇关于您如何在Jenkins中设置默认编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆