0

I've got a git repository setup (using gitblit), Jenkins and Team Foundation Server (TFS). What I am trying to do is:

1) Have engineers submit code into the git repository.

2) Jenkins will compile the code.

3) Jenkins will add the code changes into TFS.

Pretty simple right? Well I am running into an issue with reflecting deleted files in TFS. What I have working is as follows:

1) Jenkins runs a script that deletes all of the files and folders in the Jenkins workspace

2) Jenkins then clones files from the git repo to the Jenkins workspace.

git clone git://devfilesrepo.company.com/DevFiles.git %WORKSPACE%

3) Jenkins executes a batch file that has the following TFS commands:

set checkinComment=%1
tf workfold /collection:http://faketfs:8080/faketfs/DefaultCollection     /workspace:DevFiles /map $/Dev/DevFiles "C:\Jenkins\jobs\DevFiles\workspace" /login:Company\admin,fakePass
tf checkout "C:\Jenkins\jobs\DevFiles\workspace" /noprompt /recursive /login:Company\admin,fakePass
tf add "C:\Jenkins\jobs\DevFiles\workspace" /noprompt /recursive /login:Company\admin,fakePass
tf resolve /auto:KeepYours /noprompt /recursive /login:Company\admin,fakePass
tf checkin /comment:%checkinComment% /noprompt /recursive /login:Company\admin,fakePass

Now the above commands work great if a file is added or edited when it goes into Git. However, if a file is ever deleted from Git, it is not reflected in TFS.

To make the situation even more complicated. I also need to add a couple of files to TFS that should not exist in the Git repo.

Is there a TFS command I could run that would reflect the deleted changes?

I was thinking of deleting the TFS folder before adding files from Git, but then I would also be deleting the files that I added to TFS directly. I heard about Git-TF and Git-TFS, would those utilities be able to do what I am looking for? If so, what commands could I run to get the code from Git over to TFS?

Thanks

Richard Banks
  • 12,456
  • 3
  • 46
  • 62
JustAnotherDev
  • 295
  • 3
  • 13
  • I'd suggest creating a team project in TFS that uses git for source control and using that git repository as the central repo. Is there a reason why you can't/won't do that? I really don't like to see two 'sources of truth' for the code. Is the git repo the truth, or the TFVC repo? – Richard Banks Apr 17 '15 at 01:57
  • Yes, it is because we have third-party developers submit code into Git. The TFS repo sits on the intranet and we don't want to have the third-party devs have access to the intranet. – JustAnotherDev Apr 17 '15 at 16:42
  • What version of TFS are you using, by the way? And is your DevFiles workspace a server or local workspace? – Richard Banks Apr 22 '15 at 10:25
  • We are using TFS 2010, so I don't believe it supports local workspaces. – JustAnotherDev Apr 22 '15 at 16:55

1 Answers1

0

To pick up deletes, you'll want to change the approach to something like this.

  • Run the tf checkout command, as you currently do
  • Delete the folder contents via the normal command line approach, excluding the files you want to keep that aren't in git. You'll need to attrib -r the files first to turn off the read-only flag.
  • Copy the contents of the git repo into the folder
  • Use the TFS Power Tools and in particular the tfpt online command. TFS will compare the server workspace with the contents of your local file system and will add to pending changes all the adds, deletes and edits it detects. The specific command you'll want is

tfpt online /adds /deletes /diff /noprompt /recursive <folderName>

  • Run the tf resolve and tf checkin commands as you currently do.

You might need to tweak the approach a little, but that should give you what you're after.

Richard Banks
  • 12,456
  • 3
  • 46
  • 62