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

Sequential stages post section does not execute in the expected context

    XMLWordPrintable

Details

    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

            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.

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

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

            Merged, releasing as part of 1.3.1 as we speak.

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

            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.
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.

            People

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

              Dates

                Created:
                Updated:
                Resolved: