1

i wanted to setup hudson job to perform release of our project from hudson. But i have a problem: our build process is running tests that need connection to db, host:port of db is specified as system parameter. But when i try to to such system parameter to release:prepare it seems that is creates a nested process and doesn't pass any system parameters to it. How can i pass system parameter to nested process?

Can i do it with maven profiles?

Thx for any comments!

  • Can you not use a property file....? – uncaught_exceptions Apr 18 '11 at 15:05
  • Hi, what do you mean property file? I thought that release plugin should have some property that should contain all params that should be passed to its executions, but i can't find this param –  Apr 18 '11 at 15:11

2 Answers2

1

The -D properties will not be reliable propagated from the surefire-pluging to your test (I do not know why it works with eclipse). When using maven on the command line use the argLine property to wrap your property. This will pass them to your test

mvn -DargLine="-D<property>=<value>" <goal>

Use System.getProperty to read the value in your code. Have a look to this post about the difference of System.getenv and Sytem.getProperty.

(This is taken from a former answer of me.)

Community
  • 1
  • 1
FrVaBe
  • 47,963
  • 16
  • 124
  • 157
  • Thx for help, but this property needs to be also resolved in spring configuration to start an application before tests run. Is there any property in maven release plugin to specify a list of properties to pass to nested processes created by execution of release:prepare goal? –  Apr 18 '11 at 15:47
  • 3
    There is an [arguments](http://maven.apache.org/plugins/maven-release-plugin/prepare-mojo.html#arguments) property mentioned in the documentation which might is what you need? Otherwise try to declare the properties twice (-D... and -DargLine). If you want to resolve the properties in your spring configuration you should definitly consider to put them in an property file an read them with a [property-placeholder](http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/xsd-config.html#xsd-config-body-schemas-context-pphc). – FrVaBe Apr 18 '11 at 16:10
1

pom.xml can't can read system properties, see Environment variable properties. But you shouldn't write a pom tied to variables only present on a particular computer. Example: JAVA_HOME works everywhere, mydatabase.username doesn't.

The right way is to write the configuration on a properties file and read it from the pom. This way you have a documented configuration instead who-knows-what system variables. It's also less complicated than keeping a shell script with the -D parameters.

Jano
  • 62,815
  • 21
  • 164
  • 192
  • -1 for the statement _pom.xml_ can't read system properties. Have a look at the [documentation](http://maven.apache.org/pom.html#Properties) and you will see that environment variables and system properties are available in a pom.xml file. – FrVaBe Apr 19 '11 at 19:27