有没有简单的方法让TeamCity将文本或html更改日志包含为其输出工件之一?在TeamCity中创建更改日志工件
也许我需要走下有msbuild或其他进程创建更改日志的路线,但由于TeamCity为每个构建生成一个,我想知道是否已经有一个简单的方法来访问它作为工件和将其包含在工件路径指令中,以便它可以成为发行包的一部分。
有没有简单的方法让TeamCity将文本或html更改日志包含为其输出工件之一?在TeamCity中创建更改日志工件
也许我需要走下有msbuild或其他进程创建更改日志的路线,但由于TeamCity为每个构建生成一个,我想知道是否已经有一个简单的方法来访问它作为工件和将其包含在工件路径指令中,以便它可以成为发行包的一部分。
是的,改变日志是作为文件访问,此文件路径是在TeamCity的编译参数:
%system.teamcity.build.changedFiles.file%
所以,你可以这样做:
副本 “%system.teamcity.build.changedFiles.file%” changelog.txt
+1这对我来说是一个好的开始。但changelog.txt文件缺少与列出的每个文件关联的注释。你知道是否有办法得到评论吗? – slolife 2014-01-30 08:45:21
不要这样想。我们有相同的要求,最终制作了一个控制台应用程序,它访问TC的其余api以获取提交评论。然后运行这个控制台应用程序作为最终的构建步骤。 – 2014-01-30 12:46:38
可能,你应该使用Service Messages
您可以通过TeamCity的REST API生成更改日志。一个PowerShell脚本可以找到这个here:
<#
.SYNOPSIS
Generates a project change log file.
.LINK
Script posted over:
http://open.bekk.no/generating-a-project-change-log-with-teamcity-and-powershell
#>
# Where the changelog file will be created
$outputFile = "%system.teamcity.build.tempDir%\releasenotesfile_%teamcity.build.id%.txt"
# the url of teamcity server
$teamcityUrl = "%teamcity.serverUrl%"
# username/password to access Teamcity REST API
$authToken=[Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("%system.teamcity.auth.userId%:%system.teamcity.auth.password%"))
# Build id for the release notes
$buildId = %teamcity.build.id%
# Get the commit messages for the specified change id
# Ignore messages containing #ignore
# Ignore empty lines
Function GetCommitMessages($changeid)
{
$request = [System.Net.WebRequest]::Create("$teamcityUrl/httpAuth/app/rest/changes/id:$changeid")
$request.Headers.Add("AUTHORIZATION", "$authToken");
$xml = [xml](new-object System.IO.StreamReader $request.GetResponse().GetResponseStream()).ReadToEnd()
Microsoft.PowerShell.Utility\Select-Xml $xml -XPath "/change" |
where { ($_.Node["comment"].InnerText.Length -ne 0) -and (-Not $_.Node["comment"].InnerText.Contains('#ignore'))} |
foreach {"+ $($_.Node["user"].name) : $($_.Node["comment"].InnerText.Trim().Replace("`n"," "))`n"}
}
# Grab all the changes
$request = [System.Net.WebRequest]::Create("$teamcityUrl/httpAuth/app/rest/changes?build=id:$($buildId)")
$request.Headers.Add("AUTHORIZATION", "$authToken");
$xml = [xml](new-object System.IO.StreamReader $request.GetResponse().GetResponseStream()).ReadToEnd()
# Then get all commit messages for each of them
$changelog = Microsoft.PowerShell.Utility\Select-Xml $xml -XPath "/changes/change" | Foreach {GetCommitMessages($_.Node.id)}
$changelog > $outputFile
Write-Host "Changelog saved to ${outputFile}:"
$changelog
你能说明从哪里生成这个日志吗?通常将文件附加为制品不应该成为问题。 – 2013-08-27 06:32:30