简体   繁体   English

检查文件路径是否存在于不同的节点 jenkins?

[英]Check if file path exists in a different node jenkins?

Lets say I have 2 nodes:假设我有 2 个节点:

  • NodeA节点A
  • NodeB基站

I want to check if NodeB has a given directory through NodeA.我想通过 NodeA 检查 NodeB 是否有给定的目录。 Is there a way to do this through the Jenkins API?有没有办法通过 Jenkins API 做到这一点?

Expected Results预期成绩

  • NodeA should return true if the file path exists in NodeB如果 NodeB 中存在文件路径,则 NodeA 应返回 true
  • NodeA should retrun false if the file path does not exist in NodeB如果文件路径在 NodeB 中不存在,NodeA 应该返回 false

You can probably do something like this.你可能可以做这样的事情。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM