How to use post steps with Jenkins pipeline on multiple agents? : <p>When using the Jenkins pipeline where each stage runs on a different agent, it is <a href="https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Controlling-your-build-environment#3-i-like-to-drive-stick-get-out-of-my-way" rel="noreferrer">good practice</a> to use <code>agent none</code> at the beginning:</p>

<pre><code>pipeline {
  agent none
  stages {
    stage('Checkout') {
      agent { label 'master' }
      steps { script { currentBuild.result = 'SUCCESS' } }
    }
    stage('Build') {
      agent { label 'someagent' }
      steps { bat "exit 1" }
    }
  }
  post {
    always {
      step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "test@test.com", sendToIndividuals: true])
    }
  }
}
</code></pre>

<p>But doing this leads to <code>Required context class hudson.FilePath is missing</code> error message when the email should go out:</p>

<pre><code>[Pipeline] { (Declarative: Post Actions)
[Pipeline] step
Required context class hudson.FilePath is missing
Perhaps you forgot to surround the code with a step that provides this, such as: node
[Pipeline] error
[Pipeline] }
</code></pre>

<p>When I change from <code>agent none</code> to <code>agent any</code>, it works fine.</p>

<p>How can I get the <code>post</code> step to work without using <code>agent any</code>? </p>
