title: How to inject Jenkins environment variable into maven build?
body: <p>I need to get some of the Jenkins environment variables like BUILD_NUMBER and BUILD_URL and to inject them as variables in my Maven Java build.</p>
  
  <p>I have added this to the pom.xml</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;properties&gt;
      &lt;jenkins.buildUrl&gt;${env.BUILD_URL}&lt;/jenkins.buildUrl&gt;
  &lt;/properties&gt;
  </code></pre>
  
  <p>and while building with just mvn install I'm trying to get the variable by</p>
  
  <pre class="lang-java prettyprint-override"><code>private static final String JENKINS_BUILD_URL = System.getProperty("jenkins.buildUrl");
  </code></pre>
  
  <p>but unfortunately the result is null...</p>
  
  <p>What I'm doing wrong guys? </p>