我正在尝试使用巡航控制预处理器功能将我的配置分解为更小的可重用部分。我可以在根巡航控制节点中使用包含功能,如下所示:
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<cb:include href="child.config" />
</cruisecontrol>
如果我尝试在子配置中使用另一个包含(像这样):
<project name="TestProject" xmlns:cb="urn:ccnet.config.builder">
<cb:include href="grandchild.config" />
</project>
我得到以下错误:
ThoughtWorks.CruiseControl.Core.Config。ConfigurationException: Unused node detected: xmlns:cb="urn:ccnet.config.builder"
如果我删除xmlns命名空间语句,我会得到这个错误:
ThoughtWorks.CruiseControl.Core.Config。配置文件包含无效的xml: E:BuildConfigAppRiver.Tools.BuildAutomationCruiseControlccnet。config -> System.Xml.XmlException: 'cb'是一个未声明的命名空间。
最后,如果我去掉标签上的"cb"前缀,就会得到这个错误
Unused node detected: Unused node detected: <define buildFile="CP.WEB.Dev.SanityCheck.CI.build" />
我没有主意了-任何帮助都很感激!
要使用<cb:include>
, <cb:include>
标记必须定义xml命名空间,并且包含的文件必须以其中定义了xml命名空间的元素开始。这是在文档中,但很容易忽略
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<cb:include href="projectFile.xml" xmlns:cb="urn:ccnet.config.builder"/>
</cruisecontrol>
projectFile.xml
<cb:config-template xmlns:cb="urn:ccnet.config.builder">
<project>
...
</project>
</cb:config-template>
此外,如果您要添加此处提到的ccnet版本信息,则还需要在包含的文件中包含该名称空间。
所以ccnet。配置如下:
<cruisecontrol xmlns:cb="urn:ccnet.config.builder" xmlns="http://thoughtworks.org/ccnet/1/8">
<cb:include href="projectFile.xml" xmlns:cb="urn:ccnet.config.builder"/>
</cruisecontrol>
和projectFile.xml更改为
<cb:config-template xmlns:cb="urn:ccnet.config.builder" xmlns="http://thoughtworks.org/ccnet/1/8">
<project>
...
</project>
</cb:config-template>
这并不一定是包含文件的方式的问题。这是一个更普遍的错误。我遇到的问题是,在源代码控制语句中不小心遗漏了一个标记。
我想它是用来表示你插入的xml不能被你试图在
中使用它的元素所理解我不小心有这个(它适用于多源控制):
<cb:define name="Hg">
<repo>$(repo)</repo>
<executable>$(hgExePath)</executable>
<branch>default</branch>
<workingDirectory>$(dir)</workingDirectory>
</cb:define>
在下列场合使用:
<cb:define name="SourceControl">
<sourcecontrol type="hg">
<cb:Hg repo="$(repo)" dir="." />
</sourcecontrol>
</cb:define>
因为源代码控制(原生ccnet)已经指定了type="hg",所以不希望看到hg元素
尝试从Project标记中删除包含的孙子。此外,我们还包括xmlns:cb="urn:ccnet.config "。
<cb:include href="grandchild.config" xmlns:cb="urn:ccnet.config.builder"/>
如果在项目标记上放置xmlns, Cruise Control将抛出错误。这似乎是一个bug。我现在已经从Cruise Control转到了Hudson,并且非常满意。