|
I previously posted this question on the jenkins forum group and was asked to move the topic to the maven forums because this is considered a maven issue, not a jenkins issue.
Here is response and original post: Surefire does it's best to provide the forked test cases with a clean environment. Thus it will not pass through system properties unless explicitly told to. Your solution is to configure the Pom to tell Surefire to pass those properties through. Most likely this will be one of the very few cases where you may want to use a profile in your Pom. This is really a maven issue and not a Jenkins issue, so I would rather if we take it up on users@m.a.o I will be happy to help there ----- Original Post ------- We are running Jenkins ver. 1.447.1 and was hoping the latest upgrade would resolve this but the outcome is the same. The jvm arguments we are configuring in the Goals and options field are not making it into the application and unit tests when the Jenkins job executes. We are seeing the following in the console output: Executing Maven: -B -f /opt/hudson/home/jobs/alex-vendor/workspace/ pom.xml clean package -DAWS_ACCESS_KEY_ID=xxxxxxxxxxxx - DAWS_SECRET_KEY=xxxxxxxxxxxx - DJDBC_CONNECTION_STRING=jdbc:postgresql://xxxxxxxxxxxx:5432/test? user=xxxx&yyyy=aws -DPARAM1=5 -DPARAM2=localhost:8080 -DPARAM3=false This output looks great and I anticipated everything working but for whatever reason, these jvm args seem to be filtered out and never make it to our unit tests. We've even tried encapsulating each jvm arg in double quotes, but the results are the same (unit test failures). The only way we've been successful in passing these arguments is through the maven-surefire-plugin (via argLine element) which isn't adequate for us; we need to change credentials on a per job basis. Lastly, we even tried the EnvInject Plugin but unfortunately, that gave us no success as well. Does anyone see what we have misconfigured? Our application never sees the JDBC_CONNECTION_STRING jvm arg and throws an exception b/c it's missing when the job executes. Thanks for any help. - Billy - |
|
We are also trying to remove profiles altogether, this is one of the reasons we are trying to using jvm command line arguments. After simplifying things a bit further and removing jenkins out of the picture, this does appear to be a maven topic.
If I try the following command with maven 2.2.1, the jvm args are _not picked up by the unit tests and application classes (note: each jvm arg had to be encapsulated by quotes): mvn clean package "-DAWS_ACCESS_KEY_ID=xxxx" \ "-DAWS_SECRET_KEY=xxxx" \ "-DJDBC_CONNECTION_STRING=jdbc:postgresql://xxxxx:5432/test?user=xxx&password=xxx" \ "-DPARAM1=5" \ "-DPARAM2=localhost:8080" \ "-DPARAM3=false" Running the same command with maven 3 succeeds. The above was tried on my local mac: Apache Maven 2.2.1 (r801777; 2009-08-06 13:16:01-0600) Java version: 1.6.0_31 Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home Default locale: en_US, platform encoding: MacRoman OS name: "mac os x" version: "10.7.3" arch: "x86_64" Family: "mac" Running this on the same machine that jenkins is installed on succeeds with maven 2.2.1, just using maven directly, BUT it fails when jenkins attempts to execute the job with the jvm args passed in on the Goals and options field. Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400) Java version: 1.6.0_23 Java home: /usr/java/jdk1.6.0_23/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux" version: "2.6.18-164.0.0.0.1.el5xen" arch: "amd64" Family: "unix" Could it be the platform encoding? |
|
You need to see this page:
http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html You will need to define system properties for each system property you want to pass through. Most likely your properties will look like <systemPropertyVariables> <foo>${foo}</foo> <bar>${bar}</bar> </systemPropertyVariables> Ie you are just passing them straight through. You will probably want to define sensible defaults for the properties in the Pom itself so that a developer just checking out can build without changing anything... There are some times when it becomes sensible to have that set of default properties in a profile that is activated if you have not defined a touchstone property, so that once you add -Dfoo=... To the cli you need to also add the -Dbar=... As the profile with defaults is no longer active... That is the "you may need to use profiles" i was referring to, but consider it as a finesse once you have it all working. HTH -Stephen Sent from my iPhone On Thursday, 26 April 2012, billybacon wrote: > We are also trying to remove profiles altogether, this is one of the > reasons > we are trying to using jvm command line arguments. After simplifying things > a bit further and removing jenkins out of the picture, this does appear to > be a maven topic. > > If I try the following command with maven 2.2.1, the jvm args are _not > picked up by the unit tests and application classes (note: each jvm arg had > to be encapsulated by quotes): > > mvn clean package "-DAWS_ACCESS_KEY_ID=xxxx" \ > "-DAWS_SECRET_KEY=xxxx" \ > > "-DJDBC_CONNECTION_STRING=jdbc:postgresql://xxxxx:5432/test?user=xxx&password=xxx" > \ > "-DPARAM1=5" \ > "-DPARAM2=localhost:8080" \ > "-DPARAM3=false" > > Running the same command with maven 3 succeeds. > > The above was tried on my local mac: > Apache Maven 2.2.1 (r801777; 2009-08-06 13:16:01-0600) > Java version: 1.6.0_31 > Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home > Default locale: en_US, platform encoding: MacRoman > OS name: "mac os x" version: "10.7.3" arch: "x86_64" Family: "mac" > > Running this on the same machine that jenkins is installed on succeeds with > maven 2.2.1, just using maven directly, BUT it fails when jenkins attempts > to execute the job with the jvm args passed in on the Goals and options > field. > > Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400) > Java version: 1.6.0_23 > Java home: /usr/java/jdk1.6.0_23/jre > Default locale: en_US, platform encoding: UTF-8 > OS name: "linux" version: "2.6.18-164.0.0.0.1.el5xen" arch: "amd64" Family: > "unix" > > Could it be the platform encoding? > > > -- > View this message in context: > http://maven.40175.n5.nabble.com/jvm-arguments-not-making-it-to-application-and-unit-tests-tp5667993p5668007.html > Sent from the Maven - Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] <javascript:;> > For additional commands, e-mail: [hidden email]<javascript:;> > > |
|
Stephen,
This worked excellent and as advertised. Thanks so much for the suggestion and help! Thank you! - Billy -
On Thursday, April 26, 2012 at 4:08 PM, stephenconnolly [via Maven] wrote:
|
| Powered by Nabble | Edit this page |
