Advanced TeamCity usage
As can be seen on the TeamCity page FAKE is really easy to setup in TeamCity, it also support some advanced scenarios to integrate even deeper with it.
Displaying blocks in the log
By default each Target already is displayed as a collapsible block in the log file :
But blocks can be created in targets to separate operations more cleanly :
1: 2: 3: 4: 5: 6: 7: 8: |
|
Reporting artifacts
While TeamCity has a great configurability in terms of artifacts, nothing beats specifying them in code.
FAKE scripts also have the advantage of being versioned along the rest of your code, avoiding the need to keep complex artifact configurations when you need to support a new branch along with old ones or the need to configure artifacts in each build if you have multiple builds on the same repository.
1: 2: 3: 4: 5: 6: |
|
Customizing version numbers
Each build is assigned a build number in TeamCity that is available as TeamCityBuildNumber
from FAKE
and that is shown in the TeamCity dashboard :
But TeamCity also support that builds customize their version number by reporting it directly, using this feature from FAKE is simple and when coupled with other parameters reported by TeamCity can allow complex versioning schemes.
This code read versions from a release notes file and if TeamCity is detected label versions as pre-release when they come from a branch that isn't the default one or from a personal build :
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: |
|
Reporting test results
In addition to artifacts, TeamCity also allow to report test results that will be visible in the dashboard directly from the build.
Each test runner has a specific function to send it's result that can be found in the TeamCityHelper API like here for NUnit :
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: |
|
Note: NUnit version 3 is a special case as it directly support TeamCity and it's
enough to set TeamCity = (BuildServer = TeamCity)
in
it's configuration.
Full name: teamcityadvanced.printHello
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.sprintf
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
from Microsoft.FSharp.Collections
Full name: Microsoft.FSharp.Collections.Seq.iter
Full name: teamcityadvanced.releaseNotes
val int : value:'T -> int (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int
--------------------
type int = int32
Full name: Microsoft.FSharp.Core.int
--------------------
type int<'Measure> = int
Full name: Microsoft.FSharp.Core.int<_>
Full name: Microsoft.FSharp.Core.Operators.defaultArg
type Version =
new : unit -> Version + 4 overloads
member Build : int
member Clone : unit -> obj
member CompareTo : version:obj -> int + 1 overload
member Equals : obj:obj -> bool + 1 overload
member GetHashCode : unit -> int
member Major : int
member MajorRevision : int16
member Minor : int
member MinorRevision : int16
...
Full name: System.Version
--------------------
System.Version() : unit
System.Version(version: string) : unit
System.Version(major: int, minor: int) : unit
System.Version(major: int, minor: int, build: int) : unit
System.Version(major: int, minor: int, build: int, revision: int) : unit
System.Version.ToString(fieldCount: int) : string