Coder Social home page Coder Social logo

benphegan / teamcitybuildchanges Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 5.0 9.91 MB

Provides a command line utility to query changes associated with TeamCity builds. Useful to create dynamic build/release notes as part of a TeamCity build.

License: MIT License

C# 100.00%

teamcitybuildchanges's Introduction

Hi there ๐Ÿ‘‹

teamcitybuildchanges's People

Contributors

benjambe avatar benphegan avatar dipeshc avatar kl4w avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

teamcitybuildchanges's Issues

Does not pick up running builds

For a running build, need to query http:///guestAuth/app/rest/builds/?locator=running:true first to get the build number, it will not show up in the existing set of builds for a build configuration.

Enhancement to provide option to apply XML transform prior to writing XML output

Currently I'm consuming the XML output and subsequently processing the XML with XSLT to convert to formatted release notes. This is not clean in pretty much any scripting language (PowerShell for example), so it would be great to provide the following:

  1. An additional argument to enable execution of an XSLT
    • .\TeamCityBuildChanges.exe -bi ??? -x -o .\ReleaseNotes.xml -tx .\ReleaseNotes.xslt
  2. A precompiled library of stylesheets in the commandline itself, accessible by an additional argument
    • .\TeamCityBuildChanges.exe -bi ??? -x -o .\ReleaseNotes.xml -t PrettyOutput

Sample XSL (hopefully this hasn't been borked by the markdown)

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:output method="text" indent="yes" omit-xml-declaration="yes"/>
  <xsl:template match="/ArrayOfChangeDetail">
    <xsl:apply-templates select="ChangeDetail"/>
    <xsl:text>&#xd;&#xa;</xsl:text>
  </xsl:template>

  <xsl:template match="ChangeDetail">
    <xsl:text>&#xd;&#xa;</xsl:text>
    <xsl:value-of select="Version"/>
    <xsl:text> - </xsl:text>
    <xsl:value-of select="Comment"/>
    <xsl:value-of select="concat(' (', Username, ')')"/>
    <xsl:apply-templates select="Files//FileDetails" />
  </xsl:template>

  <xsl:template match="FileDetails">
    <xsl:text>&#xd;&#xa;</xsl:text>
    <xsl:text>            </xsl:text>
    <xsl:value-of select="File"/>
  </xsl:template>
</xsl:stylesheet>

AggregateBuildDeltaCommand throws an exception when querying a TeamCity build type that has not yet had a successful build

Exception logged below. Suggested fix is to fall back to the version number of the running build (i.e. match the 'to' version for a default execution).

Unhandled Exception: System.ApplicationException: Could not find latest build for build type ?????????????
[17:44:53][Step 1/4]    at TeamCityBuildChanges.Commands.AggregateBuildDeltaResolver.ResolveFromVersion(String buildType, String branchName) in z:\Work\TeamCityBuildChanges\TeamCityBuildChanges\Commands\AggregateBuildDeltaResolver.cs:line 215
[17:44:53][Step 1/4]    at TeamCityBuildChanges.Commands.AggregateBuildDeltaResolver.CreateChangeManifest(String buildName, String buildType, String referenceBuild, String from, String to, String projectName, Boolean useBuildSystemIssueResolution, Boolean recurse, String branchName) in z:\Work\TeamCityBuildChanges\TeamCityBuildChanges\Commands\AggregateBuildDeltaResolver.cs:line 88
[17:44:53][Step 1/4]    at TeamCityBuildChanges.Commands.AggregateBuildDeltaCommand.Run(String[] remainingArguments) in z:\Work\TeamCityBuildChanges\TeamCityBuildChanges\Commands\AggregateBuildDeltaCommand.cs:line 39
[17:44:53][Step 1/4]    at ManyConsole.ConsoleCommandDispatcher.DispatchCommand(IEnumerable`1 commands, String[] arguments, TextWriter consoleOut) in c:\src\ManyConsole\ManyConsole\ConsoleCommandDispatcher.cs:line 70
[17:44:53][Step 1/4]    at TeamCityBuildChanges.Program.Main(String[] args) in z:\Work\TeamCityBuildChanges\TeamCityBuildChanges\Program.cs:line 13
[17:45:29][Step 1/4] Process exited with code 255

Error resolving the running build's version number on non-default branch

Wanted to start a discussion prior to a pull request - not sure if this has been identified already. Receiving the error below (sorry about formatting) when running TeamCityBuildChanges from a build off a branch called 'develop'.

Unhandled Exception: System.ApplicationException: Could not resolve a build number for the running build. [22:26:33][Step 1/4] at TeamCityBuildChanges.Commands.AggregateBuildDeltaResolver.ResolveToVersion(String buildType) in d:\Work\TeamCityBuildChanges\TeamCityBuildChanges\Commands\AggregateBuildDeltaResolver.cs:line 198 [22:26:33][Step 1/4] at TeamCityBuildChanges.Commands.AggregateBuildDeltaResolver.CreateChangeManifest(String buildName, String buildType, String referenceBuild, String from, String to, String projectName, Boolean useBuildSystemIssueResolution, Boolean recurse) in d:\Work\TeamCityBuildChanges\TeamCityBuildChanges\Commands\AggregateBuildDeltaResolver.cs:line 88 [22:26:33][Step 1/4] at TeamCityBuildChanges.Commands.AggregateBuildDeltaCommand.Run(String[] remainingArguments) in d:\Work\TeamCityBuildChanges\TeamCityBuildChanges\Commands\AggregateBuildDeltaCommand.cs:line 37 [22:26:33][Step 1/4] at ManyConsole.ConsoleCommandDispatcher.DispatchCommand(IEnumerable1 commands, String[] arguments, TextWriter consoleOut) in c:\src\ManyConsole\ManyConsole\ConsoleCommandDispatcher.cs:line 70
[22:26:33][Step 1/4] at TeamCityBuildChanges.Program.Main(String[] args) in d:\Work\TeamCityBuildChanges\TeamCityBuildChanges\Program.cs:line 13
[22:26:42][Step 1/4] Process exited with code 255`

According to the api documentation if no branch is specified in the build locator then only builds from the default branch are returned.

branch: - since TeamCity 7.1 limit the builds by branch. can be branch name (displayed in UI, or "(name:,default:<true/false/any>,unspecified:<true/false/any>,branched:<true/false/any>)". If not specified, only builds from default branch are returned.

Tempted just to use

branch:(default:any)

Interested in thoughts around the best solution prior to opening the code.

Crashes when using -c to run against current build

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at TeamCityBuildChanges.TeamCityApi.GetReleaseNotesByBuildId(String buildId) in c:\TeamCity\BuildAgent\work\ead832b7cd39ea75\TeamCityBuildChanges\T
eamCityApi.cs:line 63
at TeamCityBuildChanges.TeamCityApi.GetReleaseNotesForCurrentBuildByBuildType(String buildType) in c:\TeamCity\BuildAgent\work\ead832b7cd39ea75\Tea
mCityBuildChanges\TeamCityApi.cs:line 75
at TeamCityBuildChanges.ReleaseNotes.Run(String[] remainingArguments) in c:\TeamCity\BuildAgent\work\ead832b7cd39ea75\TeamCityBuildChanges\ReleaseN
otes.cs:line 33
at ManyConsole.ConsoleCommandDispatcher.DispatchCommand(IEnumerable`1 commands, String[] arguments, TextWriter consoleOut) in c:\src\ManyConsole\Ma
nyConsole\ConsoleCommandDispatcher.cs:line 70
at TeamCityBuildChanges.Program.Main(String[] args) in c:\TeamCity\BuildAgent\work\ead832b7cd39ea75\TeamCityBuildChanges\Program.cs:line 12

Jira OnDemand

Downloaded this tool a couple of times before and never really got it working with our Jira Ondemand solution. Will this work with Jira Ondemand? I've tried with the following syntax:

.\TeamCityBuildChanges.exe generate --from=2014.27.0.0 --to=2014.30.0.0 -tat=6319130... -o c:\temp\releasenotes.txt --project=MS --buildName='trunk - CI' --server=http://teamcity.domain.dk --jiraurl=https://someuser:[email protected]

I get the following when executing:

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: source
at System.Linq.Enumerable.Where[TSource](IEnumerable1 source, Func2 predicate)
at TeamCityBuildChanges.ExternalApi.TeamCity.TeamCityApi.<>c__DisplayClass17.>b__15(String query) in >c:\Users\jmn\Documents\TeamCityBuildChanges\TeamCityBuildChanges\ExternalApi\Tea>mCity\TeamCityApi.cs:line 193

Any help is appreciated :)
/J.

Ensure XML output is still operational

Considering the use case such that the output of this command be piped into a tool like XMLStarlet (http://xmlstar.sourceforge.net/), we must ensure the Razor template work hasn't impeded the ability to output XML (perhaps by default, or -X switch)? I don't think it was working when I last checked.

XMLStarlet is awesome BTW, inline CLI XSLT transforms and the like :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.