-->

CruiseControl.NET:使用$(CCNetLabel)的ccnet.config文件中(

2019-07-23 11:37发布

当调用外部程序一样的MSBuild巡航控制设置环境变量。 一个值是CCNetLabel。 它拥有当前项目标签的值。 我想使用CCNET配置本身的值相同,但是当我尝试CCNET配置有问题。 我得到以下错误:

[CCNet Server:ERROR] INTERNAL ERROR: Reference to unknown symbol CCNetLabel
----------
ThoughtWorks.CruiseControl.Core.Config.Preprocessor.EvaluationException: Reference to unknown symbol CCNetLabel
at ThoughtWorks.CruiseControl.Core.Config.Preprocessor.ConfigPreprocessorEnvironment._GetConstantDef(String name)
at ThoughtWorks.CruiseControl.Core.Config.Preprocessor.ConfigPreprocessorEnvironment.eval_text_constant(String name)

.....

----------

其实我是想给CCNetLabel追加到另一个变量,所以我需要访问的ccnet.config财产。

有没有参考这些变量以不同的方式?

Answer 1:

我们有必要做这个太,发现我们可以使用替换的动态值 ,在CruiseControl.NET 1.5推出,从内部的ccnet.config访问CCNetLabel。

例如,dynamicValues阻断此片段:

  <buildpublisher>
    <sourceDir>C:\ccnet_projects\Installer\bin\x86\Release</sourceDir>
    <dynamicValues>
      <replacementValue property="publishDir">
        <format>C:\builds\installers\{0}\x86</format>
        <parameters>
          <namedValue name="$CCNetLabel" value="Default" />
        </parameters>
      </replacementValue>
    </dynamicValues>
    <useLabelSubDirectory>false</useLabelSubDirectory>
  </buildpublisher>

生成包含上飞CCNetLabelpublishDir路径:

  <buildpublisher>
    <sourceDir>C:\ccnet_projects\Installer\bin\x86\Release</sourceDir>
    <publishDir>C:\builds\installers\1.0.2.120\x86</publishDir>
    <useLabelSubDirectory>false</useLabelSubDirectory>
  </buildpublisher>      

(注意,对于此特定示例中,useLabelSubDirectory被设定为假以避免追加CCNetLabelpublishDir路径)。



Answer 2:

以下可以在配置文件中使用在CCNET版本1.5 <CB:限定buildversion = “$ [$ CCNetLabel]”/>



Answer 3:

我认为达​​里尔的答案是CCNET 1.5解决这个问题最好的办法。 关于答案就在两个意见:

  • 这是约CCNET文档正确链接动态参数 。
  • 正如你可以在文档阅读,还有一个捷径来获得你正在寻找使用语法整合财产只是价值$[$Integration_Property] 在你的情况下,使用$[$CCNetLabel]会的工作。


Answer 4:

有没有访问CCNET里面配置这些环境变量的方式。 我认为,几乎任何人谁CCNET配置(包括我自己)曾试图这样做。 此功能已被要求经常,但尚未实施。

如果你想获得CCNetWorkingDirectoryCCNetArtifactDirectory有解决方法:

<cb:define name="project.workingDirectory">c:/foo</cb:define>
<cb:define name="project.artifactDirectory">c:/bar</cb:define>
<project>
  <workingDirectory>$(project.workingDirectory)</workingDirectory>
  <artifactDirectory>$(project.artifactDirectory)</artifactDirectory>
  ...
</project>

但我不知道用于访问解决方案的CCNetLabel 。 对不起,我没有更好的消息。



Answer 5:

下面的文章应该能够帮助你。 您可以使用cb:scope的,或定义你的整个项目cb:define和传递的项目名称。

-祝好运-

http://confluence.public.thoughtworks.org/display/CCNET/Configuration+Preprocessor

http://ferventcoder.com/archive/2009/05/21/uppercut---automated-builds---cruisecontrol.net-integration.aspx



Answer 6:

我已通过添加在发布商部分的MSBuild任务(包括解决了这个CCNetLabel路径)

<msbuild>
    <executable>c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
    <workingDirectory>C:\Path\WebApp</workingDirectory>
    <projectFile>WebApp.csproj</projectFile>
    <dynamicValues>
        <replacementValue property="buildArgs">
            <format>/noconsolelogger /v:quiet /p:Configuration=Release /p:WebProjectOutputDir=c:\Publish\WebApp\{0}\ /p:OutDir=c:\Publish\WebApp\{0}\bin\</format>
            <parameters>
                <namedValue name="$CCNetLabel" value="Default" />
            </parameters>
        </replacementValue>
    </dynamicValues>                    
    <targets>ResolveReferences;_CopyWebApplication</targets>
    <timeout>600</timeout>              
</msbuild>


Answer 7:

如果使用1.5版本,那么你可以直接在MSBuild任务指定$(CCNetLabel)

 <msbuild> <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable> <workingDirectory>C:\TestApp\WindowsFormsApplication1</workingDirectory> <projectFile>WindowsFormsApplication1.sln</projectFile> <buildArgs>/p:Configuration=Debug /p:Platform="Any Cpu" /p:AssemblyVersion=$(CCNetLabel) </buildArgs> <targets>build</targets> <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger> </msbuild>    <msbuild> <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable> <workingDirectory>C:\TestApp\WindowsFormsApplication1</workingDirectory> <projectFile>WindowsFormsApplication1.sln</projectFile> <buildArgs>/p:Configuration=Debug /p:Platform="Any Cpu" /p:AssemblyVersion=$(CCNetLabel) </buildArgs> <targets>build</targets> <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger> </msbuild> 



Answer 8:

我试图做到这一点也和刚刚结束了使用南特脚本,在那里我能得到CCNetLabel像这样的环境variabl:

  <property name="version.build" value="${environment::get-variable('CCNetLabel')}"/>


文章来源: CruiseControl.NET: using $(CCNetLabel ) inside ccnet.config file