I defined several environment variables in /etc/environment, but a process (build started by TeamCity) cannot see their values. I don't know what I'm doing wrong here.. this is the content of my /etc/environment file:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
CATALINA_BASE="/var/lib/tomcat7"
CATALINA_HOME="/usr/share/tomcat7"
ACTIVEMQ_HOME="var/lib/activemq"
ACTIVEMQ_BASE="var/lib/activemq"
ACTIVEMQ_CONF="var/lib/activemq/conf"
ACTIVEMQ_DATA="var/lib/activemq/data"
ACTIVEMQ_OPTS_MEMORY="-Xms128m -Xmx192m"
M2_HOME="/usr/share/maven3"
MAVEN_HOME="/usr/share/maven3"
JAVA_HOME="/usr/lib/jvm/java-8-oracle"
The build started by TeamCity uses a Maven runner, and which at some point kicks an Ant build. Since the build was failing, I used Ant to print all environment variables in the system:
<!-- Provides all environment variables as Ant properties prefixed by "env.".
For example, CLASSPATH would be accessible in Ant as ${env.CLASSPATH} -->
<property environment="env"/>
<echo>List of all Environment Variables found in the system:</echo>
<echoproperties>
<propertyset>
<propertyref prefix="env."/>
</propertyset>
</echoproperties>
Sure enough, the ones I set in /etc/environment don't show up.
The build agent running this is started using Ubuntu's Startup app's, where I configured it to run the command:
sudo -H -u administrator /bin/bash --login -c "~administrator/BuildAgent/bin/agent.sh start"
Could it be that this line runs before /etc/environment are set?
If I do a echo $CATALINA_HOME
I see the value properly set, but the build for some reason cannot see it...
NOTE: Although I know it is the wrong way of doing it, I also tried adding export
to the declarations inside /etc/environment
, without any success. Then I removed it.
NOTE 2: I rebooted the machine after making changes to /etc/environment file, of course.
I'm on 14.04 LTS Server with minimal desktop installed (ubuntu-desktop --no--install-recommends) plus a few extras.
Any help is appreciated, thank you!
/etc/environment
only on "Linux systems without PAM." – cjs Feb 27 '18 at 10:04-i
or--login
system, and a properly configured/etc/pam.d/sudo
file,/etc/environment
is still not read. It looks like it may be a bug. – cjs Feb 27 '18 at 10:07