title: How can I configure Jenkins not to deploy to Maven repository unless I am performing a release build?
body: <p>I have configured a Jenkins job to build a Maven 3 project and with the "Maven release build" plugin enabled and also added a post-build action to deploy the artifacts to a Nexus repository.</p>
  
  <p>However, I don't want artifacts to be deployed unless the user had initiated the build by clicking the "Perform Maven Release" link instead of the "Build Now" button. When the click "Build Now" I just want a snapshot build that doesn't get deployed anywhere.</p>
  
  <p>I understood from the documentation that I could use a environment variable called IS_M2RELEASEBUILD to control this behavior. This environment variable is set to true by the M2 Release Plugin when the build was initiated via the "Perform Maven release" link. But the post build action is completely ignoring this. </p>
  
  <p><img src="https://i.stack.imgur.com/OpHPp.png" alt="Jenkins Settings"></p>
  
  <p>I am using Jenkins LTS 1.509.3 and Maven 3.0.5.</p>
  
  <p><strong>UPDATE:</strong> Please note that I am not looking for a workaround using using the Maven Release Plugin within the POM. My goal is to create a single Jenkins job that acts as the CI build (without deploying the snapshot) triggered by check-ins and to be able to use the same job to perform a release build using the Jenkins M2 Release plugin. </p>