Skip to content

Failure in Jenkins PR job due to Gitversion (System.InvalidOperationException) #2233

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
warlock2k opened this issue Apr 16, 2020 · 4 comments
Labels

Comments

@warlock2k
Copy link

warlock2k commented Apr 16, 2020

Related to #543

@arturcic Kindly help. My feature branch job passes however the pull request job fails with this error. The older Gitversion (4.0.0) on the other hand works in both cases. Could you kindly tell me if there are any breaking changes since 4.0.0 - 5.2.4?

My Jenkins job fails with the following error

[2020-04-16T19:34:42.767Z] + /tools/dotnet-gitversion /home/jenkins/agent/workspace/test_PR-850
[2020-04-16T19:34:47.364Z] INFO [04/16/20 19:34:45:63] Working directory: /home/jenkins/agent/workspace/test
[2020-04-16T19:34:47.364Z] INFO [04/16/20 19:34:46:06] Project root is: /home/jenkins/agent/workspace/test_PR-850/
[2020-04-16T19:34:47.364Z] INFO [04/16/20 19:34:46:06] DotGit directory is: /home/jenkins/agent/workspace/test_PR-850/.git
[2020-04-16T19:34:47.364Z] INFO [04/16/20 19:34:46:15] Begin: Loading version variables from disk cache
[2020-04-16T19:34:47.364Z]   INFO [04/16/20 19:34:46:15] Cache file /home/jenkins/agent/workspace/test_PR-850/.git/gitversion_cache/69712B69C28ECF0A23FAD58F141D6B380D9588C2.yml not found.
[2020-04-16T19:34:47.364Z]   INFO [04/16/20 19:34:46:15] End: Loading version variables from disk cache (Took: 2.07ms)
[2020-04-16T19:34:47.364Z]   INFO [04/16/20 19:34:46:39] Using latest commit on specified branch
[2020-04-16T19:34:47.364Z]   INFO [04/16/20 19:34:46:42] Begin: Attempting to inherit branch configuration from parent branch
[2020-04-16T19:34:47.364Z]     INFO [04/16/20 19:34:46:49] Begin: Finding branch source of 'PR-850'
[2020-04-16T19:34:47.364Z]     INFO [04/16/20 19:34:46:53] End: Finding branch source of 'PR-850' (Took: 36.37ms)
[2020-04-16T19:34:47.364Z]     INFO [04/16/20 19:34:46:53] Begin: Getting branches containing the commit 'c6922c082ca2bd92d827f2d3e5fb71ff146d1ab3'.
[2020-04-16T19:34:47.364Z]       INFO [04/16/20 19:34:46:53] Trying to find direct branches.
[2020-04-16T19:34:47.365Z]       INFO [04/16/20 19:34:46:53] No direct branches found, searching through all branches.
[2020-04-16T19:34:47.365Z]       INFO [04/16/20 19:34:46:53] Searching for commits reachable from 'origin/develop'.
[2020-04-16T19:34:47.365Z]       INFO [04/16/20 19:34:46:57] The branch 'origin/develop' has no matching commits.
[2020-04-16T19:34:47.365Z]       INFO [04/16/20 19:34:46:57] Searching for commits reachable from 'origin/hotfix/disable-xray'.
[2020-04-16T19:34:47.365Z]       INFO [04/16/20 19:34:46:59] The branch 'origin/hotfix/disable-xray' has no matching commits.
[2020-04-16T19:34:47.365Z]       INFO [04/16/20 19:34:46:59] Searching for commits reachable from 'origin/hotfix/disabled-xray-grafeas'.
[2020-04-16T19:34:47.365Z]       INFO [04/16/20 19:34:46:62] The branch 'origin/hotfix/disabled-xray-grafeas' has no matching commits.
[2020-04-16T19:34:47.365Z]       INFO [04/16/20 19:34:46:62] Searching for commits reachable from 'origin/master'.
[2020-04-16T19:34:47.365Z]       INFO [04/16/20 19:34:46:64] The branch 'origin/master' has no matching commits.
[2020-04-16T19:34:47.365Z]       INFO [04/16/20 19:34:46:64] Searching for commits reachable from 'upstream/develop'.
[2020-04-16T19:34:47.365Z]       INFO [04/16/20 19:34:46:66] The branch 'upstream/develop' has no matching commits.
[2020-04-16T19:34:47.365Z]     INFO [04/16/20 19:34:46:66] End: Getting branches containing the commit 'c6922c082ca2bd92d827f2d3e5fb71ff146d1ab3'. (Took: 130.26ms)
[2020-04-16T19:34:47.365Z]     INFO [04/16/20 19:34:46:66] Found possible parent branches: 
[2020-04-16T19:34:47.365Z]   INFO [04/16/20 19:34:46:71] End: Attempting to inherit branch configuration from parent branch (Took: 293.30ms)
[2020-04-16T19:34:47.365Z]   ERROR [04/16/20 19:34:46:98] An unexpected error occurred:
[2020-04-16T19:34:47.365Z] System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely.
[2020-04-16T19:34:47.365Z]    at GitVersion.Configuration.BranchConfigurationCalculator.InheritBranchConfiguration(Branch targetBranch, BranchConfig branchConfiguration, IList`1 excludedInheritBranches)
[2020-04-16T19:34:47.365Z]    at GitVersion.Configuration.BranchConfigurationCalculator.GetBranchConfiguration(Branch targetBranch, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Configuration\BranchConfigurationCalculator.cs:line 40
[2020-04-16T19:34:47.365Z]    at GitVersion.GitVersionContext.CalculateEffectiveConfiguration() in D:\a\GitVersion\GitVersion\src\GitVersionCore\GitVersionContext.cs:line 86
[2020-04-16T19:34:47.365Z]    at GitVersion.GitVersionContext..ctor(IRepository repository, ILog log, Branch currentBranch, Config configuration, Boolean onlyTrackedBranches, String commitId) in D:\a\GitVersion\GitVersion\src\GitVersionCore\GitVersionContext.cs:line 60
[2020-04-16T19:34:47.365Z]    at GitVersion.GitVersionCalculator.ExecuteInternal(Arguments arguments) in D:\a\GitVersion\GitVersion\src\GitVersionCore\GitVersionCalculator.cs:line 67
[2020-04-16T19:34:47.365Z]    at GitVersion.GitVersionCalculator.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersionCore\GitVersionCalculator.cs:line 45
[2020-04-16T19:34:47.365Z]    at GitVersion.GitVersionExecutor.VerifyArgumentsAndRun(Arguments arguments) in D:\a\GitVersion\GitVersion\src\GitVersionExe\GitVersionExecutor.cs:line 61
[2020-04-16T19:34:47.365Z]   INFO [04/16/20 19:34:46:98] Attempting to show the current git graph (please include in issue): 
[2020-04-16T19:34:47.365Z]   INFO [04/16/20 19:34:46:98] Showing max of 100 commits
[2020-04-16T19:34:47.365Z]   INFO [04/16/20 19:34:47:11] Could not execute 'git log' due to the following error:
[2020-04-16T19:34:47.365Z] System.IO.FileNotFoundException: The executable file 'git' could not be found.
[2020-04-16T19:34:47.365Z] File name: 'git' ---> System.ComponentModel.Win32Exception (2): No such file or directory
[2020-04-16T19:34:47.365Z]    at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
[2020-04-16T19:34:47.365Z]    at System.Diagnostics.Process.Start()
[2020-04-16T19:34:47.365Z]    at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
[2020-04-16T19:34:47.365Z]    at GitVersion.Helpers.ProcessHelper.Start(ProcessStartInfo startInfo) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Helpers\ProcessHelper.cs:line 20
[2020-04-16T19:34:47.365Z]    at GitVersion.Helpers.ProcessHelper.Start(ProcessStartInfo startInfo) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Helpers\ProcessHelper.cs:line 42
[2020-04-16T19:34:47.365Z]    at GitVersion.Helpers.ProcessHelper.Run(Action`1 output, Action`1 errorOutput, TextReader input, String exe, String args, String workingDirectory, KeyValuePair`2[] environmentalVariables) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Helpers\ProcessHelper.cs:line 120
[2020-04-16T19:34:47.365Z]    at GitVersion.Extensions.LibGitExtensions.DumpGraph(String workingDirectory, Action`1 writer, Nullable`1 maxCommits)
[2020-04-16T19:34:47.365Z] 
hudson.AbortException: script returned exit code 1[2020-04-16T19:34:48.306Z] ERROR: hudson.AbortException: hudson.AbortException: script returned exit code 1
[2020-04-16T19:34:48.348Z]     execute.call(execute.groovy:57)
[2020-04-16T19:34:48.348Z]     gitversion.call(gitversion.groovy:71)
[2020-04-16T19:34:48.447Z] ERROR: hudson.AbortException: hudson.AbortException: hudson.AbortException: script returned exit code 1
hudson.AbortException: hudson.AbortException: hudson.AbortException: hudson.AbortException: script returned exit code 1RESULT: FAILURE
+ git log -1 --format=%ae
@asbjornu
Copy link
Member

Have you tried to manually normalize the Git repository before running GitVersion? Please see #2194 for GitVersion's requirements to work properly.

@warlock2k
Copy link
Author

warlock2k commented Apr 21, 2020

@asbjornu here are my results

What worked for me is manually running the following commands before calling Gitversion in my pipeline

execute(script: 'git branch develop origin/develop', returnStdout: true, this).trim()
execute(script: 'git branch master origin/master', returnStdout: true, this).trim()

However, this is more of a workaround.

Regardin #2194:

  1. An unshallow clone - (I have unchecked shallow clone on Jenkins).
  2. An existing local master branch. (Is there a way I can do this on Jenkins instead of running the command?)
  3. Possibly an existing local develop branch (for GitFlow).
  4. A named, existing and checked out branch pointing to the commit being built (i.e. no detached HEAD).(There exists a local branch)
  5. Git_Branch as an available environment variable. (Available)

@asbjornu
Copy link
Member

So what you are saying is that ensuring point 2 and 3 made it work, @warlock2k?

@HHobeck
Copy link
Contributor

HHobeck commented Apr 2, 2023

Actually the BranchConfigurationCalculator class has not been survived on main. Please try your scenario with the 6.0.0-beta.1 preview release version and re-open this ticket if the problem persists. Thank you very much!

@HHobeck HHobeck closed this as completed Apr 2, 2023
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

3 participants