10

I got a interesting behavior in Jenkins.
Jenkins' shell does not use my systems locales.

Jenkins runs as user jenkins on my system.

Logged in as jenkins via SSH:

locale displayed:

LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
etc...

env shows LANG and LANGUAGE variables:

LANG=en_US.UTF-8
LANGUAGE=en_US:en

id shows the ID of user:

uid=1008(jenkins) gid=...

Entered above commands to a jenkins job shell:

locale displayed:

LANG=
LANGUAGE=
LC_CTYPE="POSIX"
etc...

env does not show LANG and LANGUAGE variables

id shows the ID of user (as expected):

uid=1008(jenkins) gid=...

the files:

/etc/profile contains:

export LANG=en_US.UTF-8
export LANGUAGE=en_US:en

/etc/default/locale contains:

export LANG=en_US.UTF-8
export LANGUAGE=en_US:en

startup script /etc/init.d/jenkins should export system's locales:

# load environments
if [ -r /etc/default/locale ]; then
. /etc/default/locale
export LANG LANGUAGE
elif [ -r /etc/environment ]; then
. /etc/environment
export LANG LANGUAGE
fi


Of course I rebooted after modifying the locales ;)

Apache also uses the system's locales
My system is an Ubuntu 14.04 installation.
Did I miss to check something else?

Thank you for reading!
I hope somebody can help :)

  • Jenkins seems to reset all environment variables in build shells. Check the project settings. There is also an env-inject plugin. – jofel Oct 29 '14 at 10:06
  • Your solution should be an answer, not an edit to your question... – jasonwryan Oct 31 '14 at 7:35
10

Solution:

This happens because the Jenkins master connects to the slave machine via non-interactive shell, so /etc/profile is not executed, and also /etc/default/locale does not have any effect.
non-interactive shells are usually using ~/.bashrc.

Nearly all details about this topic can be found on askubuntu:
https://askubuntu.com/questions/247738/why-is-etc-profile-not-invoked-for-non-login-shells

adding to ~/.bashrc:

export LANG=en_US.UTF-8
export LANGUAGE=en_US:en


did it for me.

This 'slave problem' is also discussed here:
https://groups.google.com/forum/#!topic/jenkinsci-users/hscDs4pKIoU https://groups.google.com/forum/#!topic/jenkinsci-users/g0fNnDltqeM Kind regards, whosit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.