How to refer environment variable in POM.xml?

user1016403 picture user1016403 · May 5, 2012 · Viewed 173.3k times · Source

I am using maven as build tool. I have set an environment variable called env. How can I get access to this environment variable's value in the pom.xml file?

Answer

Andrew White picture Andrew White · May 5, 2012

Check out the Maven Properties Guide...

As Seshagiri pointed out in the comments, ${env.VARIABLE_NAME} will do what you want.

I will add a word of warning and say that a pom.xml should completely describe your project so please use environment variables judiciously. If you make your builds dependent on your environment, they are harder to reproduce