V-next builds with a git tag can fail as it does not fetch new tags(annotated)
Deepak Kumar Mishra, Support Engineer, EMEA TFS Team, brings this knowledge experience while working with one of his customers and this important piece of information might help a lot of users who are using Git repos in tfs and build tags using TFS 2015 V-next builds.
Issue Description:
We create a tag using a following command for a git repo in TFS
Git tag -a testtag -m “message”
After this we push it to TFS server which triggers a vnext build with the tag as a part of continuous integration and then we get the following error:
Git push origin --tags
2016-09-15T07:44:15.3207410Z Starting fetch...
2016-09-15T07:44:16.2188308Z Checking out 53e2403076d27fd1476d1e4bffd453e3db146039 to C:\Agent1\_work\6\s
2016-09-15T07:44:16.2328322Z ##[error]No valid git object identified by '53e2403076d27fd1476d1e4bffd453e3db146039' exists in the repository.
2016-09-15T07:44:16.3678457Z ##[error]Prepare repository failed with exception.
The following are the screenshots of the build failure.
After this when we do a clone the v-next build succeeds.
Cause:
Libgit2sharp used to have problem while fetch annotated tags .This is a TFS bug with annotated tags which has been fixed in TFS 2016
Resolution:
1. We found that this is a bug in TFS 2015 and has been fixed in TFS 2016.
2. The workaround as of now is to use light-weight tags instead of annotated tags which solved the issue. Details of the light weight tags are available at https://git-scm.com/book/en/v2/Git-Basics-Tagging
3. The fix has been tested and it works well in TFS 2016.
Written by: Deepak Kumar Mishra
Reviewed by: Nitish Nagpal, Support Escalation Engineer