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

Sequential stages post section does not execute in the expected context

    Details

    • Similar Issues:

      Description

      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()
              }
            }
          }
        }
      }
      

        Attachments

          Issue Links

            Activity

            Hide
            abayer 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.

            Show
            abayer 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.
            Hide
            abayer 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.

            Show
            abayer 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.
            Hide
            abayer Andrew Bayer added a comment -

            Merged, releasing as part of 1.3.1 as we speak.

            Show
            abayer Andrew Bayer added a comment - Merged, releasing as part of 1.3.1 as we speak.
            Hide
            adamvoss 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.

            Show
            adamvoss 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.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                adamvoss Adam Voss
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: