title: Jenkins save artifact when build failed
body: <p>I want to Archive the artifacts of my program, but when the build failes he doesn't save the artifacts. Why is this?</p>
  
  <p>Because I only want to read the artifact when the job failed!</p>
  
  <p>Thanks for your response!</p>
  
  <p>--</p>
  
  <p>Always when the job fails, I didn't get the artifact. I test it in very small jobs:</p>
  
  <p>Empty batch file + artifact a file,
  Result: Job Succesfull,
  Artifact: succesfull</p>
  
  <p>Exit 1 in batch file + artifact a file,
  Result: Job fails,
  Artifact: didn't do anything</p>
  
  <p>config.xml file of the job:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
  &lt;project&gt;
    &lt;actions/&gt;
    &lt;description&gt;&lt;/description&gt;
    &lt;keepDependencies&gt;false&lt;/keepDependencies&gt;
    &lt;properties/&gt;
    &lt;scm class="hudson.scm.NullSCM"/&gt;
    &lt;canRoam&gt;true&lt;/canRoam&gt;
    &lt;disabled&gt;false&lt;/disabled&gt;
    &lt;blockBuildWhenDownstreamBuilding&gt;false&lt;/blockBuildWhenDownstreamBuilding&gt;
    &lt;blockBuildWhenUpstreamBuilding&gt;false&lt;/blockBuildWhenUpstreamBuilding&gt;
    &lt;triggers class="vector"/&gt;
    &lt;concurrentBuild&gt;false&lt;/concurrentBuild&gt;
    &lt;customWorkspace&gt;C:\test\&lt;/customWorkspace&gt;
    &lt;builders&gt;
      &lt;hudson.tasks.BatchFile&gt;
        &lt;command&gt;exit 1&lt;/command&gt;
      &lt;/hudson.tasks.BatchFile&gt;
    &lt;/builders&gt;
    &lt;publishers&gt;
      &lt;hudson.tasks.ArtifactArchiver&gt;
        &lt;artifacts&gt;tomcat\logs\tomcat.log&lt;/artifacts&gt;
        &lt;latestOnly&gt;false&lt;/latestOnly&gt;
      &lt;/hudson.tasks.ArtifactArchiver&gt;
    &lt;/publishers&gt;
    &lt;buildWrappers/&gt;
  &lt;/project&gt; 
  </code></pre>