Jenkins没有此类的属性插件

时间:2019-07-07 05:08:38

标签: java jenkins groovy

我正在尝试运行一个脚本来设置Jenkins Slack插件的配置。 Jenkins的版本是2.150.2。 Slack插件的版本是2.4。

运行脚本时出现错误:

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

我也尝试过使用com.cloudbees.plugins,但是它也不起作用。当我使用它时,出现以下错误:

No such property: com for class: RemoteClass

代码在这里:

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

该代码位于myscript.groovy中,并使用:

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

我希望这段代码能正常工作。 GitHub问题已经关闭,并且有报告说它正在工作。

会发生以下错误:

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)

这是从第27行触发的:

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

1 个答案:

答案 0 :(得分:0)

在Groovy中,您不使用Java语法.class来引用类文字。您只需使用类名(jenkins.plugins.slack.SlackNotifier.DescriptorImpl)。这里的.class等效于在getClass()对象上调用Class<DescriptorImpl>