Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using GitVersion on Teamcity crashes on InvalidOperationException #1825

Closed
jakubsuchybio opened this issue Sep 26, 2019 · 3 comments
Closed

Comments

@jakubsuchybio
Copy link
Contributor

jakubsuchybio commented Sep 26, 2019

Hi,
long story. I'll try to be short.
We are migrating from SVN to GIT.
We already migrated prototype, created TeamCity configuration to use GitVersionTask and it worked.
Then we found, that commit author names and emails were wrong.
We did new migration which fixed commit authors, but broke GitVersioning on Teamcity.
We didn't change anything inside GitVersion.yml.

When I install GitVersionTask as nuget to one of 160+ projects, it creates the version fine on my dev machine with this GitVersion.yml

next-version: 3.0.0
assembly-versioning-scheme: MajorMinorPatch
mode: MainLine

When I switch mode to ContinuousDelivery it works on teamcity.
When I switch mode to ContinuousDeployment it works on teamcity.
I found this in one of these:
#1671
#1625
#453

However the ContinuousDelivery or ContinuousDeployment versioning is not what we want as the final versioning scheme.

Build logs from teamcity has this error:

System.InvalidOperationException: Sequence contains no matching element
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at GitVersion.VersionCalculation.MainlineVersionCalculator.GetMainline(GitVersionContext context, Commit baseVersionSource)
at GitVersion.VersionCalculation.MainlineVersionCalculator.FindMainlineModeVersion(BaseVersion baseVersion, GitVersionContext context)
at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion(GitVersionContext context)
at GitVersion.GitVersionFinder.FindVersion(GitVersionContext context)
at GitVersion.ExecuteCore.<>c__DisplayClass7_0.<ExecuteInternal>b__0(IRepository repo)
at GitVersion.GitPreparer.WithRepository[TResult](Func`2 action)
at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache)
at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
at GitVersion.Program.VerifyArgumentsAndRun()

I tried to run the same command by hand:

gitversion.exe "C:\TeamCity\buildAgent\work\51009f2c24bb10ed" /output "buildserver" /UpdateAssemblyInfo

With added /verbosity debug, but it didn't log anything additional...

Here is the full log of that versioning step:
https://gist.github.com/jakubsuchybio/6bcc7bcc230c3a16e3cacfa29e993937

I don't know what to do here. I am pretty confident that this is a bug in GitVersion sw. Can you please try to fix this? When it showed at least 2-4times already?

If you need any additional info or some tests, just let me know.

Thanks Jacob :)

@jakubsuchybio
Copy link
Contributor Author

Ehm, I guess I figured out why.
Teamcity by default uses core.sparseCheckout true. Which I think means it doesn't download all git tree, but only the branch that is currently building.
Then I guess GitVersion can't figure out all other branches of the git tree and crashes.

However I found a hidden variable in Teamcity Git config which forces teamcity to fetch all branches.
It can be found here: https://www.jetbrains.com/help/teamcity/git.html

teamcity.git.fetchAllHeads=true

After this, the GitVersion with MainLine started to work for the cost of fetching more than needs to be fetched.

Another solution would be to set fetch remote url in GitVersion task, but I can't use that, because I run this against prototype gitlab instance which has self-signed certificate and git fetch doesn't like that. I tried to disable it in metarunner with sslVerify=false, but to no vail. :/

Hope this helps somebody.

@jakubsuchybio
Copy link
Contributor Author

I will try to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants