Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Teamcity - Perform Git Fetch for Agent-Side Checkout

I am trying to perform a full git fetch from my build agent, in order to use GitVersion in TeamCity.

I have opted to use the agent checkout option in TeamCity, as per http://gitversion.readthedocs.io/en/latest/build-server-support/build-server/teamcity/#agent-checkout

However, when I perform a checkout on the agent, I'm unable to get the full git history for a branch. I get the same result as this: https://github.com/GitTools/GitVersion/issues/912 - Specifically:

System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely.

My guess is this is because TeamCity is only checking out a subset of the repo history.

The Github issue has a workaround of performing a git fetch command at the start of every build. Is this something that TeamCity can natively support as part of a VCS root?

Thanks in advance

like image 573
Nagoh Avatar asked Oct 29 '22 23:10

Nagoh


1 Answers

TeamCity has the ability to fetch all heads TeamCity since v2017, but needs to be enabled via a config setting.

You can configure Git-plugin to fetch all heads by adding a build configuration parameter:

teamcity.git.fetchAllHeads=true.

See here for more details:

  • https://www.jetbrains.com/help/teamcity/git.html#Git-GeneralSettings
  • https://youtrack.jetbrains.com/issue/TW-24878
  • https://github.com/GitTools/GitVersion/issues/912
like image 132
MPritchard Avatar answered Nov 08 '22 05:11

MPritchard