我正在尝试以编程方式更改 SubversionSCM 插件的 Subversion 工作区格式 ( Img )。当然,我一直在尝试使用常规脚本,但我找不到任何方法。
我能够通过在 Groovy 控制台中运行此脚本来检索当前格式:
import jenkins.model.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("hudson.plugins.git.GitSCM")
desc =inst.getDescriptor("hudson.scm.SubversionSCM")
println(desc.getWorkspaceFormat())
这会打印出正确的 31。它是在“svnkit”的“ISVNWCDb”接口(interface)中找到的“WC_FORMAT_18”成员的值。您可以在插件的git存储库中看到它被使用 here .
搜索 subversion 插件的文档,我找不到任何设置它的方法,也找不到 SubversionSCM descriptor 中的任何公共(public)方法。 .
有什么方法可以以编程方式配置该设置。我更喜欢一个绝妙的脚本,但目前任何东西都可以。
最佳答案
我一直在努力解决同样的问题,并找到了一些似乎有效的方法。 正如您已经发现的,SubversionSCM 描述符上没有工作区格式的 setter ,但工作区格式作为私有(private)字段存在。
这似乎对我有用:
def required_format = 31 //31 is SVN 1.8 WF.
svn_desc = instance.getDescriptor("hudson.scm.SubversionSCM")
if(svn_desc.getWorkspaceFormat() != required_format)
{
Field wf = desc.getClass().getDeclaredField("workspaceFormat")
wf.setAccessible(true) //Private field -- make it public
wf.set(desc, required_format)
wf.setAccessible(false) //And make it private again
}
这在 Jenkins 2.122 和 Subversion 插件 2.10.6 中有效
关于jenkins - 如何在 Jenkins 中使用 Groovy 脚本设置 Subversion 工作区格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48667298/