To follow up turns out that this doesn't work as hostConfigurations appears to be only externally made visible as an unmodifiable list (unless I'm missing something).
For now perhaps the best bet is to create a fork of the plugin and add a "addHostConfiguration" method onto the descriptor which should give me what I'm after. Does that code change sound like a bit of a hack or is it something that is quite common in other plugins? Cheers Richard. On Mon, Jan 27, 2014 at 1:18 PM, Daniel Beck <[email protected]> wrote: > On 27.01.2014, at 00:33, Richard Bywater <[email protected]> wrote: > > > I'm wondering if anyone has any pointers/tips/documentation on doing so > as so far I haven't had much success in working out how to configure > Jenkins system-type configuration in an automated fashion. > > Have you tried the Script Console in Manage Jenkins, or the 'groovysh' and > 'groovy' commands in Jenkins CLI/SSH? Something similar to the following > might work (never tried it, so don't run this in production :-) ): > > --- > Jenkins.instance.getDescriptorByType(BapSshPublisherPluginDescriptor.class).with > { > List configs = [] > configs.addAll(it.hostConfigurations.getView()) > configs.add(new BapSshHostConfiguration(a bunch of arguments -- look > them up at [1])) > it.hostConfigurations.replaceBy(configs) > it.save() > } > --- > > > https://github.com/jenkinsci/publish-over-ssh-plugin/blob/master/src/main/java/jenkins/plugins/publish_over_ssh/BapSshHostConfiguration.java#L69 > > To make this more accessible and have a log, you could create a > parameterized freestyle job with a system Groovy build step (from Groovy > plugin) that contains the script. > > -- > You received this message because you are subscribed to the Google Groups > "Jenkins Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Jenkins Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
