I am new to Jenkins and to groovy scripting, I want to read a .txt file which is located in the workspace of one of the jobs. I am trying to do this way:
myfile = Jenkins.instance.getJob('JobName').workspace.readFileFromWorkspace('file.txt');
But leads to the following error:
groovy.lang.MissingMethodException: No signature of method: hudson.FilePath.readFileFromWorkspace() is applicable for argument types: (java.lang.String) values: [file.txt]