You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Make sure to use **agent checkouts** (required, server checkouts do not copy the needed `.git` directory)
21
-
- If you want to use *checkout on server*, see [dynamic repositories](../../more-info/dynamic-repositories.md)
22
-
* For the moment you need to promote the `%teamcity.build.vcs.branch.{configurationid}%` build parameter to an environment variable with the same name for pull requests to be handled correctly
20
+
When running in TeamCIty you have two options, run using **agent checkout** or use dynamic repositories.
21
+
22
+
### Agent checkout
23
+
For GitVersion to pick up pull requests properly you need to promote the `%teamcity.build.vcs.branch.{configurationid}%` variable to a system variable called `Git_Branch`
24
+
25
+
Just go to your build configuration, Parameters, click Add, Name should be `system.Git_Branch`, value should be `%teamcity.build.vcs.branch.{vcsid}%` where vcsid is your VCS root id. You should get auto completion for this.
26
+
27
+
### Dynamic repositories
28
+
To use server side checkout, you must use the dynamic repositories feature of GitVersion. Server side checkout sends just the files to the agent and not the actual .git folder. Dynamic repositories will clone your repo into a temp folder and use it to calculate version information.
29
+
30
+
See [dynamic repositories](../../more-info/dynamic-repositories.md) for more info.
31
+
32
+
### Output
23
33
* We update the TC build number to the GitVersion number automatically
24
-
* We output the individual values of the GitVersion version as the build parameter: `GitVersion.*` (Eg: `GitVersion.Major`) if you need access to them in your build script
34
+
* We output the individual values of the GitVersion version variables as build parameters with format `GitVersion.*` (Eg: `GitVersion.Major`) if you need access to them in your build script. Being system variables they will be passed as msbuild/environmental variables to other build steps
25
35
26
36
### NuGet in TeamCity
27
37
* Add dummy [parameter](http://confluence.jetbrains.com/display/TCD8/Configuring+Build+Parameters) to
28
38
the project called `GitVersion.NuGetVersion`. If many of your projects uses git-flow and SemVer you
29
-
can add the parameter to the "root-project" (TeamCity 8.x+)
39
+
can add the parameter to the "root-project" (TeamCity 8.x+). You need a dummy param because GitVersion creates the variables at runtime, and you cannot reference a paramter which is not available statically. GitVersion will overwrite the dummy value
30
40
* Then setup you nuget pack build set the "version" to `%GitVersion.NuGetVersion%`
41
+
* If you do your pack in a build script then you can just use environmental variables because teamcity will pass them through automatically.
31
42
32
43
### When TeamCity -> GitHub can't use https
33
44
GitVersion requires the presence of master branch in order to determine the version number. If TeamCity uses https to clone git repos then GitVersion will pull down master branch for you during the build.
@@ -37,29 +48,5 @@ If however your TeamCity uses SSH to clone git repos and https is unavailable th
37
48
> [GitVersionTask.UpdateAssemblyInfo] Error occurred: GitVersion.MissingBranchException: Could not fetch from '[email protected]:Xero/Bus.git' since LibGit2 does not support the transport. You have most likely cloned using SSH. If there is a remote branch named 'master' then fetch it manually, otherwise please create a local branch named 'master'. ---> LibGit2Sharp.LibGit2SharpException: An error was raised by libgit2. Category = Net (Error).
38
49
This transport isn't implemented. Sorry
39
50
40
-
You need to create a TeamCity build step before your compile step which manually creates a local master branch which tracks remote master. Like so (in powershell):
41
-
42
-
```Powershell
43
-
$branchBeingBuilt = . git symbolic-ref --short -q HEAD
0 commit comments