Here again the error message is pretty clear. Groovy can't find the object
"desc". Judging by the name, this is probably a Descriptor you are looking
for. You set the variable "global" as an instance of SonarGlobalConfiguration,
a subclass of Descriptor, using getDescriptorByType():

SonarGlobalConfiguration global = Hudson.instance.getDescriptorByType(
SonarGlobalConfiguration.class)

Perhaps you should name that variable "desc", like this:

SonarGlobalConfiguration desc =  Hudson.instance.getDescriptorByType(
SonarGlobalConfiguration.class)

Then you will have a valid object "desc" for later on in your script. Refer
to http://javadoc.jenkins.io/plugin/sonar/ and http://javadoc.jenkins.io/.

-Eric



On Fri, May 18, 2018 at 4:23 PM, naveen <[email protected]> wrote:

> Hello, Thanks for replaying me back.  Tried with your suggestion got new
> error
>
>
>
>
>
>
>
>
> ERROR: Unexpected exception occurred while performing groovy command.
>
> groovy.lang.MissingPropertyException: No such property: desc for class:
> RemoteClass
>
>         at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(Scr
> iptBytecodeAdapter.java:53)
>
>         at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.get
> Property(PogoGetPropertySite.java:52)
>
>         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGr
> oovyObjectGetProperty(AbstractCallSite.java:307)
>
>         at RemoteClass.run(RemoteClass:17)
>
>         at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(Groo
> vyShell.java:263)
>
>         at groovy.lang.GroovyShell.run(GroovyShell.java:518)
>
>         at groovy.lang.GroovyShell.run(GroovyShell.java:497)
>
>         at hudson.cli.GroovyCommand.run(GroovyCommand.java:89)
>
>         at hudson.cli.CLICommand.main(CLICommand.java:278)
>
>         at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:95)
>
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
> ssorImpl.java:62)
>
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
> thodAccessorImpl.java:43)
>
>         at java.lang.reflect.Method.invoke(Method.java:498)
>
>         at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(R
> emoteInvocationHandler.java:927)
>
>         at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(Remo
> teInvocationHandler.java:901)
>
>         at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(Remo
> teInvocationHandler.java:850)
>
>         at hudson.remoting.UserRequest.perform(UserRequest.java:210)
>
>         at hudson.remoting.UserRequest.perform(UserRequest.java:53)
>
> Something wrong in code i'm missing that.
>
> On Friday, May 18, 2018 at 12:06:12 PM UTC-7, naveen wrote:
>>
>> When I tried to configure Sonar plugin using following script throwing me
>> an error.
>>
>>
>>
>>
>>
>>
>>
>>
>> import jenkins.model.*
>>
>> import hudson.plugins.sonar.*
>>
>> import hudson.plugins.sonar.model.*
>>
>>
>>
>> def inst = Jenkins.getInstance()
>>
>> SonarGlobalConfiguration global = Hudson.instance.getDescriptorByType(
>> SonarGlobalConfiguration.class)
>>
>> def sinst = new SonarInstallation(
>>
>>   "sonar",
>>
>>   "http://localhost:9000/";,
>>
>>   "yyyyyyyyyyyyyy",
>>
>>   "3.2",
>>
>>   "",
>>
>>   new TriggersConfig(),
>>
>>   ""
>>
>> )
>>
>> desc.setInstallations(sinst)
>>
>>
>>
>> desc.save()
>>  ERROR
>>
>>
>>
>>
>>
>>
>>
>>
>> ERROR: Unexpected exception occurred while performing groovy command.
>>
>> groovy.lang.MissingPropertyException: No such property: Hudson for class:
>> RemoteClass
>>
>>         at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(Scr
>> iptBytecodeAdapter.java:53)
>>
>>         at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.get
>> Property(PogoGetPropertySite.java:52)
>>
>>         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGr
>> oovyObjectGetProperty(AbstractCallSite.java:307)
>>
>>         at RemoteClass.run(RemoteClass:6)
>>
>>         at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(Groo
>> vyShell.java:263)
>>
>>         at groovy.lang.GroovyShell.run(GroovyShell.java:518)
>>
>>         at groovy.lang.GroovyShell.run(GroovyShell.java:497)
>>
>>         at hudson.cli.GroovyCommand.run(GroovyCommand.java:89)
>>
>>         at hudson.cli.CLICommand.main(CLICommand.java:278)
>>
>>         at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:95)
>> Could someone help me in solving this script. It might be an constructor
>> issue.
>>
>> Thanks!
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" 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-users/c8008fc7-d29e-45d1-bb1a-8761db887404%40googlegroups.
> com
> <https://groups.google.com/d/msgid/jenkinsci-users/c8008fc7-d29e-45d1-bb1a-8761db887404%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Eric Pyle*
Siemens PLM Software
Lebanon, New Hampshire
+1 603-277-3060 (T)
[email protected]
http://www.siemens.com

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" 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-users/CAPrXuH28NkjwAxsaUdsxqYPQEZ5TGriiGQLmvgO5gwuKE7r2gQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to