Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using git commands in a TeamCity Build Step

One of my TeamCity v7.0 build projects relies on using a diff between the current development branch and the master branch to determine what needs to be run. I've written a small script that uses something like:

git diff origin/master..origin/QA --name-only --diff-filter=AM | DoSomethingWithThoseFiles 

Unfortunately, the build log indicates that git diff is not working. When I go into the buildAgent/work directory for this project, I see that there is no .git folder, so it cannot perform the git operations required.

I've put teamcity.git.use.local.mirrors=true in the buildAgent.properties file as mentioned at TW-15873, but that does not seem to help in any way.

Is there anything I can do to get the list of files changed between two branches in a script for my build step?

like image 548
Jake Stevenson Avatar asked Jul 24 '12 14:07

Jake Stevenson


People also ask

How does TeamCity work with GitHub?

When the new pull request is created, we can choose the branch in the target repository. This is the branch we can filter in the Pull Requests build feature settings in TeamCity. Once the pull request is submitted, TeamCity will detect that there's a new branch in the GitHub repository and will start the build.


1 Answers

Try changing the VCS checkout mode to "Always checkout files on agent" as documented here. That should give the build script access to the .git folder.

like image 161
Mike Two Avatar answered Oct 11 '22 03:10

Mike Two