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

Sequential stages post section does not execute in the expected context

      The following Jenkinsfile fails with

      Error when executing always post condition:
      org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing

      pipeline {
        agent none
      
        stages {
          stage('Hello World') {
            agent any
      
            stages {
              stage('Nested') {
                steps {
                  echo 'Hi!'
                }
              }
            }
      
            post {
              always {
                deleteDir()
              }
            }
          }
        }
      }
      

      I would expect post to run on the node selected for the 'Hello World' stage as it does in the following, working example that does not utilize sequential stages:

      pipeline {
        agent none
      
        stages {
          stage('Hello World') {
            agent any
      
            steps {
              echo 'Hi!'
            }
      
            post {
              always {
                deleteDir()
              }
            }
          }
        }
      }
      

          [JENKINS-52084] Sequential stages post section does not execute in the expected context

          Andrew Bayer added a comment -

          Your expectations are correct - I'll have to reproduce this locally but assuming I can, this is definitely a bug.

          Andrew Bayer added a comment - Your expectations are correct - I'll have to reproduce this locally but assuming I can, this is definitely a bug.

          Andrew Bayer added a comment -

          PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/272 - waiting to see if this breaks any of the existing tests, but I think it's good.

          Andrew Bayer added a comment - PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/272 - waiting to see if this breaks any of the existing tests, but I think it's good.

          Andrew Bayer added a comment -

          Merged, releasing as part of 1.3.1 as we speak.

          Andrew Bayer added a comment - Merged, releasing as part of 1.3.1 as we speak.

          Adam Voss added a comment -

          Thanks for fixing this!  Not that there was any doubt, but I installed the update and have happily (and successfully) taken advantage of this functionality in my builds.

          Adam Voss added a comment - Thanks for fixing this!  Not that there was any doubt, but I installed the update and have happily (and successfully) taken advantage of this functionality in my builds.

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.

            abayer Andrew Bayer
            adamvoss Adam Voss
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: