How to access variables outside stages in Jenkins file Groovy function?

try this

import groovy.json.*
manifestFile = "C:\\manifest.yml"

node {
  stage('Build') { 

  }
  stage('Deploy') { 
    checkDeployStatus()
  } 
}

def boolean checkDeployStatus() {
  echo "${manifestFile}"
  return true
}

Groovy has a different kind of scoping at the script level. I can't ever keep it all sorted in my head. Without trying explain all the reasons for it (and probably not doing it justice), I can tell you that (as you have seen), the manifestFile variable is not in scope in that function. Just don't declare the manifestFile (i.e. don't put def in front of it). That will make it a "global" (not really, but for your purposes here) variable, then it should be accessible in the method call.