繁体   English   中英

詹金斯类没有这样的属性插件

[英]Jenkins No such property plugins for class

我正在尝试运行一个脚本来设置 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)

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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