i am trying to establish some dynamic build parameters for a couple of Jenkins Jobs. I already found Dynamic Parameter Plug-in and Extensible Choice Parameter plugin. Both are able to use groovy scripts for their input.
Now comes the tricky part. I want to read a project.property file (the current version) and use it as default for the input. The problem was to get access to the Files in the workspace. Only the "Extensible Choice Parameter" plugin had a option to enable a convinience variable for the current project (AbstractProject) where i can get the FilePath for the workspace. See the following script:
import hudson.FilePath;
propertiesFile = new FilePath(project.getWorkspace(),"project.properties");
props = new Properties();
props.load(propertiesFile.read());
return [props["version"]]
Now this plugin only offers a list to the user (even though i can make it editable) and the major drawback is, i need to copy and paste this script to every job i want to use it (not to mention changing something for all these jobs will be a pain too).
Dynamic Parameters Plugin has a nice scriptler integration but i dont see how to get the current project. The examples do not show anything that loads the parameters from the actual workspace but only from external files.
Anyone knows how to solve either of these issues?