This is a bit of dark magic …
<pre>
<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<environmentVariables>
<SOME_ENV_VARIABLE>some value</SOME_ENV_VARIABLE>
</environmentVariables>
<systemProperties>
<property>
<name>someSystemProperty</name>
<value>${thisCanBePassedIn}</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
I’m afraid I had to update this post as initially I naively assumed that the syntax for environment variables was the same as for system properties. As you can see from above, you have to actually put a separate xml tag in there for the variable.
By putting the value in ${} you can then pass it in with -DsomeSystemProperty
from the command line when you do mvn clean install
e.g. :
mvn -DsomeSystemProperty=foobar clean install