My main goal is to use groovy to configure Jenkins and all the plugins, so that I don\'t need to manually configure Jenkins through the web interface, as the the post here w
The CreateJobAdvancedPlugin class seems to have no Descriptor. You need to get the plugin instance from the PluginManager instead, e.g.
import hudson.PluginWrapper
import hudson.plugins.createjobadvanced.CreateJobAdvancedPlugin
import jenkins.model.Jenkins
PluginWrapper wrapper = Jenkins.instance.pluginManager.getPlugin(CreateJobAdvancedPlugin)
CreateJobAdvancedPlugin plugin = wrapper.getPlugin() as CreateJobAdvancedPlugin
(Posted on behalf of the OP).
Thanks to daspilker, here's the full code that made it work:
import hudson.PluginWrapper
import hudson.plugins.createjobadvanced.CreateJobAdvancedPlugin
import jenkins.model.Jenkins
PluginWrapper wrapper = Jenkins.instance.pluginManager.getPlugin(CreateJobAdvancedPlugin)
CreateJobAdvancedPlugin plugin = wrapper.getPlugin() as CreateJobAdvancedPlugin
org.kohsuke.stapler.StaplerRequest stapler = null
net.sf.json.JSONObject jsonObject = new net.sf.json.JSONObject();
jsonObject.put("security", true);
jsonObject.put("jobspacesinname", true);
plugin.configure(stapler, jsonObject);
Just add "security", "public", "jobspacesinname", etc as found in the code. SO says I don't have enough reputation points to post more than 2 links. So to see more variables in the CreateJobAdvanced code that processes those variables, go to Github.com site, search for "createdjobadvanced-plugin" to get to the repo.
It's in /blob/352a5876f0d79f990649612a3898501663bb6980/src/main/java/hudson/plugins/createjobadvanced/CreateJobAdvancedPlugin.java#L69-L83. You'll be able to see those relevant variables and you can use add more jsonObject.put("theRelevantVariable", whateverValue);
to make changes.
This works on Jenkins 1.609.3 + CreateJobAdvanced 1.8.