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]
I was struggling to make it work for the pom modules for a file in the workspace, in the Extended Choice Parameter. Here is my solution with the printlns:
Try this: