My goal is to set a param for a class, but leave all other params default (aka set a named param).
For this class: https://javadoc.jenkins-ci.org/jenkins/slaves/RemotingWorkDirSettings.html
You can construct it either just with defaults, or passing params.
Both are valid constructors:
new RemotingWorkDirSettings()
new RemotingWorkDirSettings(boolean disabled, String workDirPath, String internalDir, boolean failIfWorkDirIsMissing)
I want to set the param failIfWorkDirIsMissing
to true, but leave everything else default.
THIS WORKS: new RemotingWorkDirSettings(false, 'a_string_here', 'b_string_here', true)
THIS DOES NOT: new RemotingWorkDirSettings(failIfWorkDirIsMissing: true)
Throws the exception:
groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: failIfWorkDirIsMissing
Questions:
How is it "readonly" when I am able to set it when I pass all the params? Since it "can" be set, it isn't truly "read only" in an explicit sense.
How can I set this parameter without having to explicitly set all the other params?**