How to refer environment variable in POM.xml?

environment-variables, java, maven, pom.xml

Solution

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

Problem

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?

Original source