0

does anyone know if it is possible to inject an environment variable into the mvn command. for example I would like to do the following in my jenkins build definition:

mvn -e -P ${env.profile} clean install assembly:assembly

my google foo is not turning up any way to do this outside the settings.xml and even that is not as dynamic as I need.

thanks in advance

Pulak Agrawal
  • 2,481
  • 4
  • 25
  • 49
peekay
  • 1,259
  • 2
  • 25
  • 49

2 Answers2

1

Just use the environment variable, directly:

Unix

mvn -e -P $profile clean install assembly:assembly

Windows

mvn -e -P %profile% clean install assembly:assembly
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • I should probably add a little more context around this. the variable is coming from a properties file. the build triggers on change of the properties file. so a simple touch command would kick off a build. in the end I want to send an email with a properties file attached that triggers the build and the contents of that properties file is what is used to populate the profile variable. unless I'm misunderstanding your example the scenario above assumes I have a constant value stored somewhere. – peekay Sep 14 '12 at 19:57
  • @peekay Checkout the documentation on profile activations (I've provided links above). – Mark O'Connor Sep 14 '12 at 21:03
0

The second answer in this post should help you. It used maven-antrun-plugin

Community
  • 1
  • 1
basiljames
  • 4,777
  • 4
  • 24
  • 41