-
Bug
-
Resolution: Unresolved
-
Minor
-
CentOS 6 on VMWare
We've discovered a weird issue when triggering some specific maven jobs : since it looks like Jenkins is re-injecting any environment variable as properties when invoking maven, it can unfortunately lead maven-war-plugin to replace some properties in xml files when building the war rather then let those properties to be defined by the webserver when the war is actually deployed.
Not sure this is an very clear description though :-p
Supposed you define MY_VAR="for_dev" as an environment variable when starting Jenkins, not sure why, but you should see this parameter appear as a java property (and its original env.MY_VAR) when debuging a maven job (clean deploy -X... - look for "properties used").
Then, if the pom file is configured to ask maven-war-plugin to replace some properties in some xml files, and those xml files are referring to ${MY_VAR} because this value will have to be expanded when the war will be deployed in the container (ex: MY_VAR="for_prod", this value will unfortunately be overwritten during the build using the build server setting (MY_VAR="for_dev") ! The setting will therefore by hard-coded in the war with the "for_dev" value !
It's probably a good practice to not mix all the environment variables so Jenkins will not know anything about MY_VAR on the first place (this setting will only be used on by the container running the targeted webapp after all).
But we still think it's weird to find all the environment variables "re-injected" as Java properties in every maven jobs !
This does not happened if maven is called with the same parameters and environment variables in a shell step. Which suggest this injection is done by the Jenkins plugin invoking maven ?
If some variable might have to be passed as java properties (for some good reason maybe), it should not be the case for all of them, right ?
We have not yet tried this with 1.533, but we don't see any info in the change log that will lead us to think this behavior has been impacted since 1.531.