Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-43578

Declarative pipeline: post section doesn't play nice with agent none


      Hi, so using the declarative pipeline it appears if you have agent none set at the top of the pipeline and agents defined per stage, you are unable to have a post section that executes certain steps (that require a node context). The following will result in an error::

      pipeline {
          agent none
          stages {
              stage('Example') {
                  steps {
                      echo 'Hello World'
          post { 
              always { 
      Required context class hudson.FilePath is missing
      Perhaps you forgot to surround the code with a step that provides this, such as: node
      ERROR: Attempted to execute a step that requires a node context while agent none was specified. Be sure to specify your own node { ... } blocks when using agent none.

      I'm guessing its expected behavior but would it be possible to associate an agent with the post section as we do with stages?

      Thanks, David


            abayer Andrew Bayer
            davidshepard77 david shepard
            0 Vote for this issue
            10 Start watching this issue