-
Bug
-
Resolution: Fixed
-
Critical
-
None
-
Platform: PC, OS: Windows XP
Hudson 1.315 running in Tomcat 6, 64-bit Java 1.6.0_14 JVM, on Win2k3 server.
Environment variables set in the main Hudson configuration are not passed to
Maven tasks, neither are they available for use in options (e.g. MAVEN_OPTS)
MAVEN_OPTS as defined in the job is passed directly to the JVM via the command
line. Inserting %MAVEN_OPTS% (Windows style) or $MAVEN_OPTS or ${MAVEN_OPTS} as
suggested in help popout do not expand the existing variable, but instead get
inserted as literal text, stopping the process.
Verified by running Maven help:system goal. This lists Java system properties
and environment variables. Neither MAVEN_OPTS or the test TEST_STUPID_VAR were
present, and the effects that MAVEN_OPTS should have on the JVM properties (in
particular settings file.encoding) were not present either.
This in direct contradiction of the release notes, which say that this should
work. Reviewing the patch quoted at the bottom of issue 3644 this only seems to
apply to the M2 release plugin.
To be honest, I would have expected all environment variables defined in the
Hudson config to be visible to all processes forked from Hudson - or else what's
the point of having them at all? Environment expansion in all job settings is a
natural convenience, and being able to also set environment variables in job
types would also be useful.
If you set the system environment variable MAVEN_OPTS, that value is then
available for expansion, but you have to explicitly specify that you want to use it
e.g.
I set MAVEN_OPTS=-Dfile.encoding=utf-8
Running a mvn help:system build tells me that my file.encoding is Cp1252
Then I configure that job to have MAVEN_OPTS of ${MAVEN_OPTS} and run again. My
file.encoding is now utf-8 as intended.
Maven jobs should use MAVEN_OPTS if it's defined in the environment. And the
environment should include variables defined by Hudson.