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

Sequential stages post section does not execute in the expected context

XMLWordPrintable

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

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

              Created:
              Updated:
              Resolved: