【发布时间】:2019-02-05 21:47:08
【问题描述】:
警告:我很擅长 EnterpriseLinux,但假设我对 Jenkins、jars、wars、jpis、java 和 groovy 充其量只是一个不情愿的行人。真的很抱歉。
我在 RHEL7 上设置了一个 Jenkins 盒子,主要是通过(诚然腐烂的)Chef 食谱,所以它是可重复的并且几乎是防白痴的。在添加模块时,我通过本地文件(安全站点,无网络访问)添加 HPI,如下所示:
plugins=%w(active-directory mailer display-url-api)
require 'digest'
plugins
.each_with_index do |plugin_with_version, index|
p, v = plugin_with_version.split(':') # yeah I know
source = "#{Chef::Config[:file_cache_path]}/cookbooks/#{cookbook_name}/files/default/#{p}.hpi"
directory "#{node['jenkins']['master']['home']}/plugins" do
owner node['jenkins']['master']['user']
group node['jenkins']['master']['group']
mode 0755
end
cookbook_file "#{node['jenkins']['master']['home']}/plugins/#{p}.hpi" do
action :create
owner node['jenkins']['master']['user']
group node['jenkins']['master']['group']
mode 0755
notifies :create, "ruby_block[jenkins_restart_flag]", :immediately
end
end
当我使用 HPI 对文件部分进行预游戏时,它会填充 /var/lib/jenkins/plugins 位置,所以我想我到了那里。
# ls -l /var/lib/jenkins/plugins/
total 708
drwxr-xr-x 6 jenkins jenkins 77 Aug 30 08:37 active-directory
-rwxr-xr-x 1 jenkins jenkins 583280 Aug 30 08:37 active-directory.hpi
drwxr-xr-x 4 jenkins jenkins 53 Aug 30 08:37 display-url-api
-rwxr-xr-x 1 jenkins jenkins 19478 Aug 30 08:37 display-url-api.hpi
drwxr-xr-x 4 jenkins jenkins 53 Aug 30 08:37 mailer
-rwxr-xr-x 1 jenkins jenkins 115745 Aug 30 08:37 mailer.hpi
实际上,这三个插件似乎都在 /pluginManager/installed 中处于活动状态:
active directory plugin 2.8
Display URL API 2.2.0
Mailer Plugin 1.21
.. 两个部门的复选框被选中并变暗,其中 AD 插件被选中。这表明它们已安装并激活,但我猜。
我想现在配置 AD 插件,这就是今天出现严重错误的地方。
Here是我正在使用的脚本,aboutthe5thsuchscript(当大脑没有线索时,谷歌是我唯一的朋友):
import hudson.plugins.active_directory.*
import jenkins.model.*
def instance = Jenkins.getInstance();
def ActiveDirectoryDomain adDomain = new ActiveDirectoryDomain("Example_Domain_Name_2", "Example_Domain_Controller_\
2");
def domains = new ArrayList<ActiveDirectoryDomain>();
domains.add(adDomain);
def securityRealm = new ActiveDirectorySecurityRealm(
"",
domains,
"",
"",
"",
"",
GroupLookupStrategy.RECURSIVE,
false,
true,
null)
println(securityRealm.domains)
instance.setSecurityRealm(securityRealm)
instance.save()
但调用完全保释。删除厨师咩咩声的错误消息的实质是:
---- Begin output of "/usr/lib/jvm/java-1.8.0/bin/java" -jar "/var/chef/cache/jenkins-cli.jar" -s http://localhost:8080 -"remoting" groovy = ----
STDOUT:
STDERR: Aug 30, 2018 1:32:03 PM org.jenkinsci.remoting.util.AnonymousClassWarnings warn
WARNING: Attempt to (de-)serialize anonymous class hudson.cli.ClientAuthenticationCache$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
ERROR: Unexpected exception occurred while performing groovy command.
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: hudson.plugins.active_directory.ActiveDirectorySecurityRealm(java.lang.String, java.util.ArrayList, java.lang.String, java.lang.String, java.lang.String, java.lang.String, hudson.plugins.active_directory.GroupLookupStrategy, java.lang.Boolean, java.lang.Boolean, null)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1732)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1532)
at org.codehaus.groovy.runtime.callsite.MetaClassConstructorSite.callConstructor(MetaClassConstructorSite.java:49)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
at RemoteClass.run(RemoteClass:9)
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:280)
at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
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)
---- End output of "/usr/lib/jvm/java-1.8.0/bin/java" -jar "/var/chef/cache/jenkins-cli.jar" -s http://localhost:8080 -"remoting" groovy = ----
没有喜悦,对吧?这是最好的剪辑:
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: hudson.plugins.active_directory.ActiveDirectorySecurityRealm(java.lang.String, java.util.ArrayList, java.lang.String, java.lang.String, java.lang.String, java.lang.String, hudson.plugins.active_directory.GroupLookupStrategy, java.lang.Boolean, java.lang.Boolean, null)
现在,在我们深入研究这个之前,我想说的是,我也尝试过的其他(实际上是 3 或 4 个)脚本,比如 Internet van-candy,也因类似的构造函数错误而被保释。如果需要,我可以运行这些并显示错误以进行比较,但我想建议的是它闻起来像一个更大的问题,不知何故我的插件并没有放入它们应该是的代码中,即使看起来一切都很好.再次,仍在猜测。
是的,在另外 3-4 次尝试中,我使用内部自定义数据调整了脚本;这一个,士气低落,我什至都懒得理会。但我保证我会使用有效数据和其他数据,如果我们能够克服构造函数错误,计划是使用真实值。
以及问题,按照非常特殊的顺序:
- groovy 创建该 AD 配置的已知良好调用是什么?最新的似乎是一个非常变化的代码库?
- 有没有其他人看到这个具有类似设置的 groovy 构造函数问题?
- 有什么提示可以让我更接近胜利吗?
感谢您阅读本文,希望您的一天一切顺利。 ;-)
【问题讨论】:
标签: jenkins groovy active-directory chef-infra rhel7