title: jenkins: ERROR: M2_HOME is set to an invalid directory
body: <p>I use Jenkins to run my tests. Also I use Maven to build tests.
  Then I try to run job I get:</p>
  
  <pre><code>ERROR: M2_HOME is set to an invalid directory.
  M2_HOME = "C:\test\TestProject\.."
  Please set the M2_HOME variable in your environment to match the
  location of the Maven installation
  
  Build step 'Invoke top-level Maven targets' marked build as failure
  Finished: FAILURE
  </code></pre>
  
  <p>I set M2_HOME in System Variables and it is C:\apache-maven-3.1.1.
  Job settings in Jenkins are:</p>
  
  <p>Advanced Project Options:
   Use custom workspace
   Directory - C:\test\TestProject\
  Source Code Management: 
   None
  Build:
   Root POM - pom.xml
   Goals and options  - clean test </p>
  
  <p>How can I fix this? How can I find from where M2_HOME variable is taken?</p>