简体   繁体   中英

Jenkins No such property plugins for class

I'm trying to run a script to set the configuration for the Jenkins Slack plugin. The version of Jenkins is 2.150.2. The version of the Slack plugin is 2.4.

When the script is run I get an error:

No such property: plugins for class: hudson.model.Hudson

I've tried using com.cloudbees.plugins as well but that it not working either. When I use this I get the following error:

No such property: com for class: RemoteClass

The code is here:

https://github.com/jenkinsci/slack-plugin/issues/427#issuecomment-444024289

The code is placed in myscript.groovy and run with:

java -jar jenkins-cli.jar -s http://localhost:8080 -"remoting" groovy myscript.groovy

I expect this code to work. The GitHub issue has been closed and there is a report of it working.

What happens is I get the following error:

ERROR: Unexpected exception occurred while performing groovy command.
groovy.lang.MissingPropertyException: No such property: plugins for class: hudson.model.Hudson
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
    at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:66)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
    at RemoteClass.run(RemoteClass:33)
    at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.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:283)
    at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:95)
    at sun.reflect.GeneratedMethodAccessor245.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:929)
    at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:903)
    at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:855)
    at hudson.remoting.UserRequest.perform(UserRequest.java:212)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:369)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at hudson.cli.CliManagerImpl$1.call(CliManagerImpl.java:66)
    at hudson.remoting.CallableDecoratorAdapter.call(CallableDecoratorAdapter.java:18)
    at hudson.remoting.CallableDecoratorList$1.call(CallableDecoratorList.java:21)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

This is being triggered from line 27:

def slack = jenkins.getDescriptorByType(jenkins.plugins.slack.SlackNotifier.DescriptorImpl.class)

In Groovy, you don't use the Java syntax .class to refer to a class literal; you just use the class name ( jenkins.plugins.slack.SlackNotifier.DescriptorImpl ). The .class here is equivalent to calling getClass() on the Class<DescriptorImpl> object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM