Home > database >  Check if file path exists in a different node jenkins?
Check if file path exists in a different node jenkins?

Time:12-02

Lets say I have 2 nodes:

  • NodeA
  • NodeB

I want to check if NodeB has a given directory through NodeA. Is there a way to do this through the Jenkins API?

Expected Results

  • NodeA should return true if the file path exists in NodeB
  • NodeA should retrun false if the file path does not exist in NodeB

CodePudding user response:

You can probably do something like this.

def isDirAvailable() {
  def isAvailble = false;
  node('NodeA') {
     if(fileExists("/Path/to/dir")){
        isAvailble = true;
      }
  }
  return isAvailble;
}
  • Related