gpt4 book ai didi

version-control - 如何将内部版本号从 Nant 传递回 Cruise Control

转载 作者:行者123 更新时间:2023-12-04 14:37:28 26 4
gpt4 key购买 nike

我有一个 Nant 构建脚本,CruiseControl 使用它来按需构建解决方案。

但是,我们最近才获得 CruiseControl,因此我们的官方内部版本号与 CruiseControl 中列出的不同。

我知道 CruiseControl 将一些属性注入(inject)到构建脚本中,以便我可以在脚本 (CCNetLabel) 中访问 CC 内部版本号,但是如何将值传递回 CC 以用作 UI 屏幕上的内部版本号?

例如,CC 表示内部版本号 2

nAnt 脚本每次构建都会增加一个 buildnumber.xml 值,官方的构建号是 123。

我希望 CC UI 显示最后一个成功的内部版本号:123,而不是 2,那么我如何将该值传递回来?

最佳答案

为此需要自定义构建标签。 Perforce 是我们的源代码控制提供商,我们从中获得了我们的版本号。代码如下:

/// <summary>
/// Gets the latest change list number from perforce, for ccnet to consume as a build label.
/// </summary>
[ReflectorType( "p4labeller" )]
public class PerforceLabeller : ILabeller
{
// perforce executable (optional)
[ReflectorProperty("executable", Required = false)]
public string P4Executable = "p4.exe";

// perforce port (i.e. myserver:1234)
[ReflectorProperty("port", Required = false)]
public string P4Port = String.Empty;

// perforce user
[ReflectorProperty("user", Required = false)]
public string P4User = String.Empty;

// perforce client
[ReflectorProperty("client", Required = false)]
public string P4Client = String.Empty;

// perforce view (i.e. //Dev/Code1/...)
[ReflectorProperty("view", Required = false)]
public string P4View = String.Empty;

// Returns latest change list
public string Generate( IIntegrationResult previousLabel )
{
return GetLatestChangelist();
}

// Stores latest change list into a label
public void Run( IIntegrationResult result )
{
result.Label = GetLatestChangelist();
}

// Gets the latest change list
public string GetLatestChangelist()
{
// Build the arguments to pass to p4 to get the latest changelist
string theArgs = "-p " + P4Port + " -u " + P4User + " -c " + P4Client + " changes -m 1 -s submitted " + P4View;
Log.Info( string.Format( "Getting latest change from Perforce using --> " + theArgs ) );

// Execute p4
ProcessResult theProcessResult = new ProcessExecutor().Execute( new ProcessInfo( P4Executable, theArgs ) );

// Extract the changelist # from the result
Regex theRegex = new Regex( @"\s[0-9]+\s", RegexOptions.IgnoreCase );
Match theMatch = theRegex.Match( theProcessResult.StandardOutput );
return theMatch.Value.Trim();
}
}

方法, 获取最新更改列表 , 是你可能会插入你自己的逻辑来与你的版本控制系统对话的地方。在 Perforce 中,最后一个变更列表的想法是独一无二的。我们的内部版本号以及最终的版本号都基于此。

一旦你构建了它(到一个程序集 dll 中),你就必须把它挂到 ccnet 中。您可以将程序集放入服务器目录(ccnet.exe 旁边)。

接下来,您修改您的 ccnet 项目文件以使用此贴标机。我们用 default labeller block 做到了这一点.类似于以下内容:
<project>
<labeller type="p4labeller">
<client>myclient</client>
<executable>p4.exe</executable>
<port>myserver:1234</port>
<user>myuser</user>
<view>//Code1/...</view>
</labeller>
<!-- Other project configuration to go here -->
</project>

如果您只是想让内部版本号显示在 ccnet 中,那么您就完成了,不需要做任何其他事情。但是,如果您愿意,可以使用已提供的 访问 NAnt 脚本中的标签。 CCNetLabel 属性(property)。

希望这会有所帮助。如果您有任何问题,请通过评论告诉我。

关于version-control - 如何将内部版本号从 Nant 传递回 Cruise Control,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/268289/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com