gre*_*ade 15 teamcity continuous-integration changelog
有没有一种简单的方法让TeamCity包含一个text或html change-log作为其输出工件之一?
也许我需要沿着让msbuild或其他进程创建更改日志的路线,但是当TeamCity为每个构建生成一个时,我想知道是否已经有一种简单的方法来将其作为工件访问并将其包含在工件路径指令,以便它可以作为发布包的一部分.
pet*_*ven 12
是的,更改日志可作为文件访问,此文件的路径位于TeamCity构建参数中:
%system.teamcity.build.changedFiles.file%
Run Code Online (Sandbox Code Playgroud)
所以你可以这样做:
copy "%system.teamcity.build.changedFiles.file%" changelog.txt
Run Code Online (Sandbox Code Playgroud)
Dan*_*ose 12
您可以通过TeamCity的REST API生成更改日志.可以在此处找到PowerShell脚本:
<#
.SYNOPSIS
Generates a project change log file.
.LINK
Script posted over:
http://open.bekk.no/generating-a-project-change-log-with-teamcity-and-powershell
Also See https://stackoverflow.com/questions/4317409/create-changelog-artifact-in-teamcity
#>
# 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", "Basic $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", "Basic $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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4596 次 |
| 最近记录: |