Is this an appropriate place to ask this kind of question?
---------- Forwarded message ----------
From: Guy Matz <[email protected]>
Date: Tue, Mar 6, 2018 at 5:34 PM
Subject: Using StaplerRequest to configure a plugin?
To: [email protected]
Hi! Does anyone know how to automate the configuration of a plugin using a
StaplerRequest object? I'm trying to configure scm-sync-configuration with:
import net.sf.json.JSONObject
import org.kohsuke.stapler.StaplerRequest
import hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin
def params = [
noUserCommitMessage: false,
displayStatus: true,
scm: 'hudson.plugins.scm_sync_configuration.scms.
ScmSyncGitSCM',
gitRepositoryUrl: '[email protected]:GroupM-mPlatform/ci.git',
commitMessagePattern: '[message]',
manualSynchronizationIncludes: 'asdfasdf'
]
def JSONObject formData = [ params ] as JSONObject
scm = new ScmSyncConfigurationPlugin().getInstance()
println("SCMs? ${scm.getScms()}")
StaplerRequest req = [
getParameter: { name ->
// println(params[name])
params[name]
}
] as org.kohsuke.stapler.StaplerRequest
scm.configure(req, formData)
It seems to almost work a little - uncommenting "println(params[name])"
tells me that it's getting processed a bit - but then it bombs with:
java.lang.UnsupportedOperationException
at org.codehaus.groovy.runtime.ConvertedMap.invokeCustom(
ConvertedMap.java:52)
at org.codehaus.groovy.runtime.ConversionHandler.invoke(
ConversionHandler.java:124)
at com.sun.proxy.$Proxy51.getParameterValues(Unknown Source)
at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin.
configure(ScmSyncConfigurationPlugin.java:218)
at
hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin$configure.call(Unknown
Source)
The source at line 218 of ScmSyncConfigurationPlugin is:
if(req.getParameterValues("manualSynchronizationIncludes") != null){
...
}
Any thoughts out there? :-(
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/CABnTgtVjWvzp7UHcUftVAtNbY48OdrWeNn4wOQJwZj6Kkqj66A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.