title: Jenkins: Publish over SSH after failed build
body: <p>I am trying to use the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Publish+Over+SSH+Plugin" rel="nofollow">Publish Over SSH</a> plugin to publish many kinds of build artifact to an external server. Examples of build artifacts are compiled builds, XML output from testing, and JSON output from linting.</p>
  
  <p>If testing or linting results in errors, the build will fail or be marked unstable. In the case of a failed build, the Publish Over SSH plugin will not copy the build artifacts, writing to the console:</p>
  
  <pre><code>SSH: Current build result is [FAILURE], not going to run.
  </code></pre>
  
  <p>I see no reason why I wouldn't want to publish this information if it exists, and I would like to continue to report errors as build failures. So, is there any way to force Jenkins to publish build artifacts even if the job is marked as a failure?</p>
  
  <p>I thought I could use the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Flexible+Publish+Plugin" rel="nofollow">Flexible Publish</a> to force this, by wrapping the Publish Over SSH in an "always" condition, but this gave the same output as before on a build failure.</p>
  
  <p>I can think of a couple of work-arounds:</p>
  
  <p>a) store the build status in an environment variable; force the status to SUCCESS; perform the publish step; recover the build status from the environment variable using <code>java jenkins-cli.jar set-build-status $STORED_STATUS</code></p>
  
  <p>OR</p>
  
  <p>b) Write a bash script to perform the publishing step manually using SSH, cutting out the Publish Over SSH plugin altogether</p>
  
  <p>Before I push forward with either of these solutions (neither of which I like), is there any piece of configuration that I'm missing?</p>