Skip to content

GitVersion.Tool throws exception and returns exit code 0 #2000

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

Closed
matkoch opened this issue Dec 19, 2019 · 7 comments
Closed

GitVersion.Tool throws exception and returns exit code 0 #2000

matkoch opened this issue Dec 19, 2019 · 7 comments
Labels

Comments

@matkoch
Copy link
Contributor

matkoch commented Dec 19, 2019

Even though there clearly is an error, the exit code is 0.

[19:42:13]	[Clean]
INFO [12/19/19 19:42:13:01] Applicable build agent found: 'TeamCity'.
INFO [12/19/19 19:42:13:02] Working directory: /var/www/TeamCity/buildAgent/work/eff7cbc1aff2d3e
INFO [12/19/19 19:42:13:02] IsDynamicGitRepository: False
INFO [12/19/19 19:42:13:04] Returning Project Root from DotGitDirectory: /var/www/TeamCity/buildAgent/work/eff7cbc1aff2d3e/.git/ - /var/www/TeamCity/buildAgent/work/eff7cbc1aff2d3e/
INFO [12/19/19 19:42:13:05] Running on Unix.
INFO [12/19/19 19:42:13:05] Applicable build agent found: 'TeamCity'.INFO [12/19/19 19:42:13:05] Branch from build environment: master
INFO [12/19/19 19:42:13:05] Begin: Normalizing git directory for branch 'master'  
INFO [12/19/19 19:42:13:10] One remote found (origin -> 'https://github.com/XX/YY').  
INFO [12/19/19 19:42:13:10] Fetching from remote 'origin' using the following refspecs: +refs/heads/*:refs/remotes/origin/*.  
INFO [12/19/19 19:42:13:17] End: Normalizing git directory for branch 'master' (Took: 122.44ms)  
ERROR [12/19/19 19:42:13:20] An unexpected error occurred:
[19:42:13]	[Clean] LibGit2Sharp.LibGit2SharpException: remote authentication required but no callback set
[19:42:13]	[Clean]    at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
[19:42:13]	[Clean]    at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
[19:42:13]	[Clean]    at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteHandle remote, IEnumerable`1 refSpecs, GitFetchOptions fetchOptions, String logMessage)
[19:42:13]	[Clean]    at LibGit2Sharp.Commands.Fetch(Repository repository, String remote, IEnumerable`1 refspecs, FetchOptions options, String logMessage)
[19:42:13]	[Clean]    at GitVersion.Helpers.GitRepositoryHelper.Fetch(ILog log, AuthenticationInfo authentication, Remote remote, Repository repo) in D:\a\1\s\src\GitVersionCore\Helpers\GitRepositoryHelper.cs:line 145
[19:42:13]	[Clean]    at GitVersion.Helpers.GitRepositoryHelper.NormalizeGitDirectory(ILog log, IEnvironment environment, String gitDirectory, AuthenticationInfo authentication, Boolean noFetch, String currentBranch, Boolean isDynamicRepository) in D:\a\1\s\src\GitVersionCore\Helpers\GitRepositoryHelper.cs:line 40
[19:42:13]	[Clean]    at GitVersion.GitPreparer.Prepare(Boolean normalizeGitDirectory, String currentBranch, Boolean shouldCleanUpRemotes) in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 51
[19:42:13]	[Clean]    at GitVersion.GitVersionCalculator.CalculateVersionVariables() in D:\a\1\s\src\GitVersionCore\GitVersionCalculator.cs:line 52
[19:42:13]	[Clean]    at GitVersion.ExecCommand.Execute() in D:\a\1\s\src\GitVersionExe\ExecCommand.cs:line 40
[19:42:13]	[Clean]    at GitVersion.GitVersionExecutor.VerifyArgumentsAndRun(Arguments arguments) in D:\a\1\s\src\GitVersionExe\GitVersionExecutor.cs:line 117  INFO [12/19/19 19:42:13:20]   INFO [12/19/19 19:42:13:20] Attempting to show the current git graph (please include in issue):   INFO [12/19/19 19:42:13:20] Showing max of 100 commits
@matkoch
Copy link
Contributor Author

matkoch commented Dec 19, 2019

@JoshClose

@matkoch
Copy link
Contributor Author

matkoch commented Jan 4, 2020

Forgot to mention, this is GitVersion.Tool. I suspect that's relevant.

@asbjornu
Copy link
Member

asbjornu commented Jan 6, 2020

Are the environment variables GITVERSION_REMOTE_USERNAME and GITVERSION_REMOTE_PASSWORD defined as per the documentation?

@matkoch
Copy link
Contributor Author

matkoch commented Jan 6, 2020 via email

@arturcic arturcic added the bug label Jan 6, 2020
@asbjornu
Copy link
Member

asbjornu commented Jan 7, 2020

Ah, so in the absence of these environment variables and the resulting exceptions due to their absence, GitVersion still produces an exit code of 0? That's a bug indeed.

@VLZZZ
Copy link

VLZZZ commented Feb 10, 2020

+1 for the exit code issues.
I've had several different situations when an Error produced but in all cases exit code was 0.

e.g.

❯ gitversion; echo -e "\n\nEXIT_CODE: $?"

INFO [02/10/20 21:41:56:80] Working directory: /opt/test-releaseINFO [02/10/20 21:41:56:81] IsDynamicGitRepository: FalseINFO [02/10/20 21:41:56:82] Returning Project Root from DotGitDirectory: /opt/test-release/.git/ - /opt/test-release/INFO [02/10/20 21:41:56:82] Running on Unix.INFO [02/10/20 21:41:56:82] Project root is: /opt/test-release/INFO [02/10/20 21:41:56:82] DotGit directory is: /opt/test-release/.gitINFO [02/10/20 21:41:56:87] Begin: Loading version variables from disk cache  INFO [02/10/20 21:41:56:87] Cache file /opt/test-release/.git/gitversion_cache/47B6B3F3BFE65B464C9A7A33AF8058E6E82CE7F8.yml not found.  INFO [02/10/20 21:41:56:87] End: Loading version variables from disk cache (Took: 3.60ms)  ERROR [02/10/20 21:41:57:04] An unexpected error occurred:
GitVersion.Configuration.GitVersionConfigurationException: Branch configuration 'all' is missing required configuration 'source-branches'

See http://gitversion.readthedocs.io/en/latest/configuration/ for more info
   at GitVersion.Configuration.ConfigExtensions.Reset(Config config)
   at GitVersion.Configuration.ConfigProvider.Provide(String workingDirectory, Boolean applyDefaults, Config overrideConfig)
   at GitVersion.Configuration.ConfigProvider.Provide(Boolean applyDefaults, Config overrideConfig)
   at GitVersion.GitVersionCalculator.ExecuteInternal(String targetBranch, String commitId, Config overrideConfig)
   at GitVersion.GitVersionCalculator.GetCachedGitVersionInfo(String targetBranch, String commitId, Config overrideConfig, Boolean noCache)
   at GitVersion.GitVersionCalculator.CalculateVersionVariables()
   at GitVersion.ExecCommand.Execute()
   at GitVersion.GitVersionExecutor.VerifyArgumentsAndRun(Arguments arguments)  INFO [02/10/20 21:41:57:04]   INFO [02/10/20 21:41:57:04] Attempting to show the current git graph (please include in issue):   INFO [02/10/20 21:41:57:04] Showing max of 100 commits

EXIT_CODE: 0

@arturcic
Copy link
Member

I think this one was fixed here #2161. Please check the version 5.2.4 and confirm it was fixed. Closing. reopen if still reproducing

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

No branches or pull requests

4 participants