GitVersion
GitVersion copied to clipboard
[Bug] SyntaxError: Unexpected end of JSON input
Describe the bug In our Azure DevOps Pipeline, we are trying to specify the path to an externalized GitVersion.yaml which is in the Resources repo we also use for ADO templates.
When we specify the configFilePath to the yaml, we receive the error: ##[error]SyntaxError: Unexpected end of JSON input
I can confirm the file is physically available in the working directory and also the GitVersion.yaml works on my local macbook without issues.
We are running on a self-managed linux vm
Expected Behavior
We would expect the extension to be able to take the input for the location where the configuration file is located, read it, and use it during the pipeline duration.
Actual Behavior
We receive an error: ##[error]SyntaxError: Unexpected end of JSON input
Full log output of task:
starting: Execute GitVersion
==============================================================================
Task : Execute GitVersion Task
Description : Easy Semantic Versioning (http://semver.org) for projects using Git
Version : 0.9.9
Author : GitTools Contributors
Help : See the [documentation](https://gitversion.net/docs/) for help
==============================================================================
Command: dotnet-gitversion /home/azureado/agent/_work/6/s /output json /output buildserver /config /home/azureado/agent/_work/6/s/ado-templates/vars/GitVersion.yml
/home/azureado/agent/_work/_tool/GitVersion.Tool/5.6.9/x64/dotnet-gitversion /home/azureado/agent/_work/6/s /output json /output buildserver /config /home/azureado/agent/_work/6/s/ado-templates/vars/GitVersion.yml
Cannot find the .git directory
INFO [05/13/21 19:24:29:60] Working directory: /home/azureado/agent/_work/6/s
INFO [05/13/21 19:24:29:64] Done writing
##[error]SyntaxError: Unexpected end of JSON input
Finishing: Execute GitVersion
Possible Fix
The only workaround we have is to commit the GitVersion.yaml directly into the repo being built.
So far, have not found any way to get an external file to read successfully
Steps to Reproduce
- stage: DetermineVersion
jobs:
- job: ExecuteGitVersion
workspace:
clean: all
steps:
- checkout: self
- checkout: templates
- task: gitversion/setup@0
inputs:
versionSpec: '5.6.x'
- task: gitversion/execute@0
displayName: Execute GitVersion
name: Version
inputs:
useConfigFile: true
configFilePath: '$(Build.SourcesDirectory)/$(reponame)/GitVersion.yml'
The contents of GitVersion.yaml:
branches:
main:
regex: ^master$|^main$
mode: ContinuousDelivery
tag: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
tracks-release-branches: true
is-release-branch: false
release:
regex: ^releases?[/-]
mode: ContinuousDelivery
tag: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
tracks-release-branches: false
is-release-branch: true
pre-release-weight: 1000
feature:
regex: ^features?[/-]
mode: ContinuousDelivery
tag: useBranchName
increment: Inherit
prevent-increment-of-merged-branch-version: false
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
pull-request:
regex: ^(pull|pull\-requests|pr)[/-]
mode: ContinuousDelivery
tag: PullRequest
increment: Inherit
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
hotfix:
regex: ^hotfix(es)?[/-]
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
support:
regex: ^support[/-]
mode: ContinuousDelivery
tag: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
develop:
regex: ^dev(elop)?(ment)?$
mode: ContinuousDeployment
tag: unstable
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
tracks-release-branches: true
is-release-branch: false
Context
We are trying to tune gitversion to provide semantic versions differently than the plugin defaults, so we can control the versioning increment as desired by our organization. Without this, we are getting alpha and beta tags on our releases, which is not desired.
Your Environment
- Version Used: GitVersion Task version: 0.9.9, GitVersion.Tool 5.6.9 x64
ADO agent version 2.184.2 Linux, CentOS 7
Perhaps related to #2567.
I am having exactly the same issue. Cannot find the .git directory and Unexpected end of JSON.
I've narrowed it down to be because of using the following in the pipeline for the job that calculates version: - checkout: none persistCredentials: "true"
Of course by not checking out, it wont even sync to a git repository, so the .git folder stays empty. The reason it was working sometimes and not others for us, was because some of our Azure DevOps agents still had the workspace mapped from a previous build of the same repository (pre breaking changes), therefore meaning the .git folder was already present.
I am facing the same issue. Any idea how to solve it or troubleshoot it? Thanks
UPDATE - I manage to solve it: an existing release branch had wrong name (v1.0.0.0). I deleted the branch and the task run successfully
I've hit a similar, error message today - Possible workaround (if related) is to fix/specify the versionSpec
to a working version (e.g. 5.9.0
) as mentioned in #3007. This seems to have resolved this error for me in the short term.
Version 5.9.0
didn't work for me with self-hosted agents. Version 5.10.1
does work for me. See also [Bug] Version 5.10 is causing "SyntaxError: Unexpected end of JSON input" error
Example azure-pipelines.yml
steps:
- task: gitversion/setup@0
inputs:
versionSpec: '5.10.1'
Im using version 5.10.3 and im getting the same issue
at LibGit2Sharp.Core.LazyGroup`1.Dependent`2.Evaluate() in /_/LibGit2Sharp/Core/LazyGroup.cs:line 80
at LibGit2Sharp.Core.LazyGroup`1.Dependent`2.get_Value() in /_/LibGit2Sharp/Core/LazyGroup.cs:line 73
at LibGit2Sharp.Commit.get_Committer() in /_/LibGit2Sharp/Commit.cs:line 87
at GitVersion.Commit..ctor(Commit innerCommit) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\Commit.cs:line 17
at GitVersion.Commit.<>c.<.ctor>b__3_0(Commit parent) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\Commit.cs:line 16
at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
at GitVersion.Configuration.BranchConfigurationCalculator.InheritBranchConfiguration(Int32 recursions, IBranch targetBranch, BranchConfig branchConfiguration, ICommit currentCommit, Config configuration, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Configuration\BranchConfigurationCalculator.cs:line 77
at GitVersion.Configuration.BranchConfigurationCalculator.GetBranchConfigurationInternal(Int32 recursions, IBranch targetBranch, ICommit currentCommit, Config configuration, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Configuration\BranchConfigurationCalculator.cs:line 54
at GitVersion.Configuration.BranchConfigurationCalculator.GetBranchConfiguration(IBranch targetBranch, ICommit currentCommit, Config configuration, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Configuration\BranchConfigurationCalculator.cs:line 28
at GitVersion.GitVersionContextFactory.Create(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionContextFactory.cs:line 39
at GitVersion.GitVersionCoreModule.<>c__DisplayClass0_0.<RegisterTypes>b__1() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\GitVersionCoreModule.cs:line 37
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at GitVersion.VersionCalculation.NextVersionCalculator.get_context() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\NextVersionCalculator.cs:line 15
at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\NextVersionCalculator.cs:line 30
at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 52
at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 66
INFO [09/10/22 6:14:52:39] Attempting to show the current git graph (please include in issue):
INFO [09/10/22 6:14:52:39] Showing max of 100 commits
INFO [09/10/22 6:14:52:42] * 334fe5b 8 minutes ago (grafted, HEAD -> feature/NL-8-stroybook-pipeline-AK, origin/334fe5b27bd62651df8e3471cfa9d5967f770f86, 334fe5b27bd62651df8e3471cfa9d5967f770f86)
INFO [09/10/22 6:14:52:44] Done writing
##[error]SyntaxError: Unexpected end of JSON input
I've hit this issue again today on GitVersion v5.9.0 and also tried v5.10.3 (and an older v5.7.0) - All hit the Unexpected end of JSON input
error.
Oddly, I've only hit this issue on a couple of repos that I've created today in Azure DevOps Services - Other builds that were using GitVersion v5.9.0 were working OK and have been for a while since my previous post in this thread.
Given that it only seemed to be impacting the new repos and the error message also seemed to state that it couldn't find the initial/first commit, I'd been able to create a new repo in Azure DevOps, initialize it locally/offline then push a commit back to the remote, Azure DevOps repo - I noted that GitVersion did work sucessfully in the build on the initial/single commit, but then failed once a second commit was added to the master
branch.
I'm not clear how to resolve this for these new repos at present, and am unclear why this isn't also impacting the older/existing repos that use the same build templates that make use of the same version of GitVersion (existing repos/builds work on v5.9.0 and v5.10.3, but new repos fail on both).
I can only think it's something in GitVersion potentially not supporting a later/newer version of Git, perhaps (I'm now using Git 2.37.2.windows.2
locally and Azure DevOps, hosted build pool is using Git 2.37.3
), but possibly steming/caused from/by the initial creation/initialization of the repo, rather than something post-creation...not sure?!
Any help/suggestions would be appreciated.
Build Log Following 2nd Commit, using v5.10.3 (Checkout task):
2022-09-10T14:02:54.9289360Z ##[section]Starting: Checkout aa.TestTerraformRepo2@master to s
2022-09-10T14:02:54.9294503Z ==============================================================================
2022-09-10T14:02:54.9294768Z Task : Get sources
2022-09-10T14:02:54.9295033Z Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2022-09-10T14:02:54.9295292Z Version : 1.0.0
2022-09-10T14:02:54.9295457Z Author : Microsoft
2022-09-10T14:02:54.9296147Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2022-09-10T14:02:54.9296456Z ==============================================================================
2022-09-10T14:02:55.3693861Z Syncing repository: aa.TestTerraformRepo2 (Git)
2022-09-10T14:02:56.0678276Z ##[command]git version
2022-09-10T14:02:56.4330181Z git version 2.37.3
2022-09-10T14:02:56.4352679Z ##[command]git lfs version
2022-09-10T14:02:57.2709054Z git-lfs/3.2.0 (GitHub; linux amd64; go 1.18.2)
2022-09-10T14:02:57.2879136Z ##[command]git init "/home/vsts/work/1/s"
2022-09-10T14:02:57.3318932Z hint: Using 'master' as the name for the initial branch. This default branch name
2022-09-10T14:02:57.3331177Z hint: is subject to change. To configure the initial branch name to use in all
2022-09-10T14:02:57.3331763Z hint: of your new repositories, which will suppress this warning, call:
2022-09-10T14:02:57.3332144Z hint:
2022-09-10T14:02:57.3332831Z hint: git config --global init.defaultBranch <name>
2022-09-10T14:02:57.3333212Z hint:
2022-09-10T14:02:57.3333764Z hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
2022-09-10T14:02:57.3334422Z hint: 'development'. The just-created branch can be renamed via this command:
2022-09-10T14:02:57.3334813Z hint:
2022-09-10T14:02:57.3335230Z hint: git branch -m <name>
2022-09-10T14:02:57.3335587Z Initialized empty Git repository in /home/vsts/work/1/s/.git/
2022-09-10T14:02:57.3367991Z ##[command]git remote add origin https://[email protected]/someorg/SomeOrg.Dev/_git/aa.TestTerraformRepo2
2022-09-10T14:02:57.3503322Z ##[command]git config gc.auto 0
2022-09-10T14:02:57.3520763Z ##[command]git config --get-all http.https://[email protected]/someorg/SomeOrg.Dev/_git/aa.TestTerraformRepo2.extraheader
2022-09-10T14:02:57.3790357Z ##[command]git config --get-all http.extraheader
2022-09-10T14:02:57.3821510Z ##[command]git config --get-regexp .*extraheader
2022-09-10T14:02:57.3852342Z ##[command]git config --get-all http.proxy
2022-09-10T14:02:57.3889571Z ##[command]git config http.version HTTP/1.1
2022-09-10T14:02:57.3958095Z ##[command]git --config-env=http.extraheader=env_var_http.extraheader fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin --depth=1 +0cc23883b1010cb85e812b8c326e74e2916411ad:refs/remotes/origin/0cc23883b1010cb85e812b8c326e74e2916411ad
2022-09-10T14:02:57.8616701Z remote: Azure Repos
2022-09-10T14:02:57.8618812Z remote:
2022-09-10T14:02:57.8619995Z remote: Found 5 objects to send. (32 ms)
2022-09-10T14:02:57.8629558Z From https://dev.azure.com/someorg/SomeOrg.Dev/_git/aa.TestTerraformRepo2
2022-09-10T14:02:57.8646139Z * [new ref] 0cc23883b1010cb85e812b8c326e74e2916411ad -> origin/0cc23883b1010cb85e812b8c326e74e2916411ad
2022-09-10T14:02:57.9091663Z ##[command]git --config-env=http.extraheader=env_var_http.extraheader fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin --depth=1 +0cc23883b1010cb85e812b8c326e74e2916411ad
2022-09-10T14:02:58.1470408Z remote: Azure Repos
2022-09-10T14:02:58.1470889Z remote:
2022-09-10T14:02:58.1471495Z remote: Found 0 objects to send. (17 ms)
2022-09-10T14:02:58.1472301Z From https://dev.azure.com/someorg/SomeOrg.Dev/_git/aa.TestTerraformRepo2
2022-09-10T14:02:58.1490381Z * branch 0cc23883b1010cb85e812b8c326e74e2916411ad -> FETCH_HEAD
2022-09-10T14:02:58.1878613Z ##[command]git checkout --progress --force refs/remotes/origin/0cc23883b1010cb85e812b8c326e74e2916411ad
2022-09-10T14:02:58.1884276Z Note: switching to 'refs/remotes/origin/0cc23883b1010cb85e812b8c326e74e2916411ad'.
2022-09-10T14:02:58.1885089Z
2022-09-10T14:02:58.1885546Z You are in 'detached HEAD' state. You can look around, make experimental
2022-09-10T14:02:58.1885935Z changes and commit them, and you can discard any commits you make in this
2022-09-10T14:02:58.1886302Z state without impacting any branches by switching back to a branch.
2022-09-10T14:02:58.1886481Z
2022-09-10T14:02:58.1886747Z If you want to create a new branch to retain commits you create, you may
2022-09-10T14:02:58.1887263Z do so (now or later) by using -c with the switch command. Example:
2022-09-10T14:02:58.1887429Z
2022-09-10T14:02:58.1887782Z git switch -c <new-branch-name>
2022-09-10T14:02:58.1888000Z
2022-09-10T14:02:58.1888225Z Or undo this operation with:
2022-09-10T14:02:58.1888343Z
2022-09-10T14:02:58.1888657Z git switch -
2022-09-10T14:02:58.1888755Z
2022-09-10T14:02:58.1889046Z Turn off this advice by setting config variable advice.detachedHead to false
2022-09-10T14:02:58.1889235Z
2022-09-10T14:02:58.1889454Z HEAD is now at 0cc2388 Added test.txt
2022-09-10T14:02:58.1891714Z ##[command]git config http.https://[email protected]/someorg/SomeOrg.Dev/_git/aa.TestTerraformRepo2.extraheader "AUTHORIZATION: placeholder_7ffda57e-e055-407e-86b5-ea409f4f5a30"
2022-09-10T14:02:58.1935769Z ##[section]Finishing: Checkout aa.TestTerraformRepo2@master to s
Build Log Following 2nd Commit (same build as above), using v5.10.3 (GitVersion task - FAILS):
2022-09-10T14:03:06.1222692Z ##[section]Starting: GitVersion - Execute
2022-09-10T14:03:06.1229837Z ==============================================================================
2022-09-10T14:03:06.1230122Z Task : Execute GitVersion Task
2022-09-10T14:03:06.1230406Z Description : Easy Semantic Versioning (http://semver.org) for projects using Git
2022-09-10T14:03:06.1230649Z Version : 0.9.13
2022-09-10T14:03:06.1230850Z Author : GitTools Contributors
2022-09-10T14:03:06.1231130Z Help : See the [documentation](https://gitversion.net/docs/) for help
2022-09-10T14:03:06.1231439Z ==============================================================================
2022-09-10T14:03:06.3102197Z Command: dotnet-gitversion /home/vsts/work/1/s /output json /output buildserver
2022-09-10T14:03:06.3116117Z [command]/opt/hostedtoolcache/GitVersion.Tool/5.10.3/x64/dotnet-gitversion /home/vsts/work/1/s /output json /output buildserver
2022-09-10T14:03:06.7903847Z ERROR [09/10/22 14:03:06:72] An unexpected error occurred:
2022-09-10T14:03:06.7904836Z INFO [09/10/22 14:03:06:52] Working directory: /home/vsts/work/1/s
2022-09-10T14:03:06.7907111Z GitVersion.GitVersionException: Cannot find commit 0cc2388 Added test.txt. Please ensure that the repository is an unshallow clone with `git fetch --unshallow`.
2022-09-10T14:03:06.7907691Z INFO [09/10/22 14:03:06:55] Project root is: /home/vsts/work/1/s/
2022-09-10T14:03:06.7909283Z ---> LibGit2Sharp.NotFoundException: object not found - no match for id (1e277a5031a279ff45d9acd8d0f132083a17523f)
2022-09-10T14:03:06.7909758Z INFO [09/10/22 14:03:06:55] DotGit directory is: /home/vsts/work/1/s/.git
2022-09-10T14:03:06.7910979Z at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
2022-09-10T14:03:06.7911720Z INFO [09/10/22 14:03:06:55] Branch from build environment: refs/heads/master
2022-09-10T14:03:06.7912925Z at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 172
2022-09-10T14:03:06.7913657Z INFO [09/10/22 14:03:06:55] Begin: Normalizing git directory for branch 'refs/heads/master'
2022-09-10T14:03:06.7914972Z at LibGit2Sharp.Core.Proxy.git_revwalk_next(RevWalkerHandle walker) in /_/LibGit2Sharp/Core/Proxy.cs:line 2774
2022-09-10T14:03:06.7915789Z INFO [09/10/22 14:03:06:58] One remote found (origin -> 'https://[email protected]/someorg/SomeOrg.Dev/_git/aa.TestTerraformRepo2').
2022-09-10T14:03:06.7917090Z at LibGit2Sharp.CommitLog.CommitEnumerator.MoveNext() in /_/LibGit2Sharp/CommitLog.cs:line 140
2022-09-10T14:03:06.7917794Z INFO [09/10/22 14:03:06:58] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
2022-09-10T14:03:06.7918892Z INFO [09/10/22 14:03:06:59] Creating local branch master
2022-09-10T14:03:06.7919467Z at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
2022-09-10T14:03:06.7920408Z INFO [09/10/22 14:03:06:61] Creating local branch from remote tracking 'refs/remotes/origin/0cc23883b1010cb85e812b8c326e74e2916411ad'.
2022-09-10T14:03:06.7921666Z at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
2022-09-10T14:03:06.7922341Z INFO [09/10/22 14:03:06:62] HEAD points at branch 'refs/heads/master'.
2022-09-10T14:03:06.7923525Z at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
2022-09-10T14:03:06.7924234Z INFO [09/10/22 14:03:06:62] End: Normalizing git directory for branch 'refs/heads/master' (Took: 77.91ms)
2022-09-10T14:03:06.7925527Z at GitVersion.RepositoryStore.GetBaseVersionSource(ICommit currentBranchTip) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 67
2022-09-10T14:03:06.7926094Z INFO [09/10/22 14:03:06:63] Begin: Loading version variables from disk cache
2022-09-10T14:03:06.7927310Z --- End of inner exception stack trace ---
2022-09-10T14:03:06.7927845Z INFO [09/10/22 14:03:06:63] Cache file /home/vsts/work/1/s/.git/gitversion_cache/7EBCF5AFDF2C95AD6C84E0A4628038FD07FFD924.yml not found.
2022-09-10T14:03:06.7929002Z INFO [09/10/22 14:03:06:63] End: Loading version variables from disk cache (Took: 0.34ms)
2022-09-10T14:03:06.7929584Z INFO [09/10/22 14:03:06:64] Using latest commit on specified branch
2022-09-10T14:03:06.7930053Z INFO [09/10/22 14:03:06:67] Running against branch: master (0cc2388 Added test.txt)
2022-09-10T14:03:06.7930508Z INFO [09/10/22 14:03:06:67] Begin: Calculating base versions
2022-09-10T14:03:06.7931004Z INFO [09/10/22 14:03:06:69] End: Calculating base versions (Took: 17.91ms)
2022-09-10T14:03:06.7931441Z INFO [09/10/22 14:03:06:72] Attempting to show the current git graph (please include in issue):
2022-09-10T14:03:06.7931915Z INFO [09/10/22 14:03:06:72] Showing max of 100 commits
2022-09-10T14:03:06.7933054Z INFO [09/10/22 14:03:06:76] * 0cc2388 39 seconds ago (grafted, HEAD -> master, origin/0cc23883b1010cb85e812b8c326e74e2916411ad, 0cc23883b1010cb85e812b8c326e74e2916411ad)
2022-09-10T14:03:06.7933449Z
2022-09-10T14:03:06.7933929Z INFO [09/10/22 14:03:06:47] Applicable build agent found: 'AzurePipelines'.
2022-09-10T14:03:06.7934386Z INFO [09/10/22 14:03:06:52] Working directory: /home/vsts/work/1/s
2022-09-10T14:03:06.7934803Z INFO [09/10/22 14:03:06:55] Project root is: /home/vsts/work/1/s/
2022-09-10T14:03:06.7935225Z INFO [09/10/22 14:03:06:55] DotGit directory is: /home/vsts/work/1/s/.git
2022-09-10T14:03:06.7935624Z INFO [09/10/22 14:03:06:55] Branch from build environment: refs/heads/master
2022-09-10T14:03:06.7936273Z INFO [09/10/22 14:03:06:55] Begin: Normalizing git directory for branch 'refs/heads/master'
2022-09-10T14:03:06.7937082Z INFO [09/10/22 14:03:06:58] One remote found (origin -> 'https://[email protected]/someorg/SomeOrg.Dev/_git/aa.TestTerraformRepo2').
2022-09-10T14:03:06.7937981Z INFO [09/10/22 14:03:06:58] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
2022-09-10T14:03:06.7938539Z INFO [09/10/22 14:03:06:59] Creating local branch master
2022-09-10T14:03:06.7939289Z INFO [09/10/22 14:03:06:61] Creating local branch from remote tracking 'refs/remotes/origin/0cc23883b1010cb85e812b8c326e74e2916411ad'.
2022-09-10T14:03:06.7939939Z INFO [09/10/22 14:03:06:62] HEAD points at branch 'refs/heads/master'.
2022-09-10T14:03:06.7940611Z INFO [09/10/22 14:03:06:62] End: Normalizing git directory for branch 'refs/heads/master' (Took: 77.91ms)
2022-09-10T14:03:06.7941107Z INFO [09/10/22 14:03:06:63] Begin: Loading version variables from disk cache
2022-09-10T14:03:06.7941651Z INFO [09/10/22 14:03:06:63] Cache file /home/vsts/work/1/s/.git/gitversion_cache/7EBCF5AFDF2C95AD6C84E0A4628038FD07FFD924.yml not found.
2022-09-10T14:03:06.7942218Z INFO [09/10/22 14:03:06:63] End: Loading version variables from disk cache (Took: 0.34ms)
2022-09-10T14:03:06.7942629Z INFO [09/10/22 14:03:06:64] Using latest commit on specified branch
2022-09-10T14:03:06.7943117Z INFO [09/10/22 14:03:06:67] Running against branch: master (0cc2388 Added test.txt)
2022-09-10T14:03:06.7943800Z at GitVersion.RepositoryStore.GetBaseVersionSource(ICommit currentBranchTip) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 71
2022-09-10T14:03:06.7947233Z at GitVersion.VersionCalculation.FallbackVersionStrategy.GetVersions()+MoveNext() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\BaseVersionCalculators\FallbackVersionStrategy.cs:line 23
2022-09-10T14:03:06.7948246Z at GitVersion.VersionCalculation.BaseVersionCalculator.GetBaseVersions(IVersionStrategy strategy)+MoveNext() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\BaseVersionCalculator.cs:line 102
2022-09-10T14:03:06.7948939Z at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
2022-09-10T14:03:06.7949561Z at GitVersion.VersionCalculation.BaseVersionCalculator.GetBaseVersion() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\BaseVersionCalculator.cs:line 31
2022-09-10T14:03:06.7950456Z at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\NextVersionCalculator.cs:line 52
2022-09-10T14:03:06.7951596Z at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 52
2022-09-10T14:03:06.7952361Z at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 66
2022-09-10T14:03:06.7952994Z INFO [09/10/22 14:03:06:67] Begin: Calculating base versions
2022-09-10T14:03:06.7953454Z INFO [09/10/22 14:03:06:69] End: Calculating base versions (Took: 17.91ms)
2022-09-10T14:03:06.7953890Z ERROR [09/10/22 14:03:06:72] An unexpected error occurred:
2022-09-10T14:03:06.7954734Z GitVersion.GitVersionException: Cannot find commit 0cc2388 Added test.txt. Please ensure that the repository is an unshallow clone with `git fetch --unshallow`.
2022-09-10T14:03:06.7955584Z ---> LibGit2Sharp.NotFoundException: object not found - no match for id (1e277a5031a279ff45d9acd8d0f132083a17523f)
2022-09-10T14:03:06.7956141Z at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
2022-09-10T14:03:06.7956809Z at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 172
2022-09-10T14:03:06.7957360Z at LibGit2Sharp.Core.Proxy.git_revwalk_next(RevWalkerHandle walker) in /_/LibGit2Sharp/Core/Proxy.cs:line 2774
2022-09-10T14:03:06.7958825Z at LibGit2Sharp.CommitLog.CommitEnumerator.MoveNext() in /_/LibGit2Sharp/CommitLog.cs:line 140
2022-09-10T14:03:06.7959526Z at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
2022-09-10T14:03:06.7960701Z at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
2022-09-10T14:03:06.7961223Z at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
2022-09-10T14:03:06.7961803Z at GitVersion.RepositoryStore.GetBaseVersionSource(ICommit currentBranchTip) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 67
2022-09-10T14:03:06.7962548Z --- End of inner exception stack trace ---
2022-09-10T14:03:06.7963097Z at GitVersion.RepositoryStore.GetBaseVersionSource(ICommit currentBranchTip) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 71
2022-09-10T14:03:06.7963935Z at GitVersion.VersionCalculation.FallbackVersionStrategy.GetVersions()+MoveNext() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\BaseVersionCalculators\FallbackVersionStrategy.cs:line 23
2022-09-10T14:03:06.7964867Z at GitVersion.VersionCalculation.BaseVersionCalculator.GetBaseVersions(IVersionStrategy strategy)+MoveNext() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\BaseVersionCalculator.cs:line 102
2022-09-10T14:03:06.7965562Z at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
2022-09-10T14:03:06.7966221Z at GitVersion.VersionCalculation.BaseVersionCalculator.GetBaseVersion() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\BaseVersionCalculator.cs:line 31
2022-09-10T14:03:06.7967030Z at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\NextVersionCalculator.cs:line 52
2022-09-10T14:03:06.7967758Z at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 52
2022-09-10T14:03:06.7968520Z at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 66
2022-09-10T14:03:06.7969152Z INFO [09/10/22 14:03:06:72] Attempting to show the current git graph (please include in issue):
2022-09-10T14:03:06.7969685Z INFO [09/10/22 14:03:06:72] Showing max of 100 commits
2022-09-10T14:03:06.7970530Z INFO [09/10/22 14:03:06:76] * 0cc2388 39 seconds ago (grafted, HEAD -> master, origin/0cc23883b1010cb85e812b8c326e74e2916411ad, 0cc23883b1010cb85e812b8c326e74e2916411ad)
2022-09-10T14:03:06.7970872Z
2022-09-10T14:03:06.7971167Z INFO [09/10/22 14:03:06:78] Done writing
2022-09-10T14:03:06.7999606Z ##[error]SyntaxError: Unexpected end of JSON input
2022-09-10T14:03:06.8011342Z ##[section]Finishing: GitVersion - Execute
``
@SphenicPaul, the argument --depth=1
makes the repository being cloned a shallow clone, which will cause GitVersion to crash. When GitVersion crashes and outputs an exception instead of valid JSON, the AzDO Task and GitHub Action will mask the error by instead throwing the Unexpected end of JSON input
error. Please see https://github.com/GitTools/GitVersion/issues/3091#issuecomment-1240999129 for how to do a full clone in AzDO.
Thanks @asbjornu - that link and solution has been able to resolve/workaround the problem I was hitting.
Much appreciated.
I'm glad @SphenicPaul. As this is a bug in the task/action and not within GitVersion itself, I'm closing in favor of https://github.com/GitTools/actions/issues/730.
Even though this ticket is closed, I'd like to share a task definition that solved the issue for me:
- task: CmdLine@2
inputs:
script: 'git fetch --unshallow --update-shallow'
Be sure to use persistCredentials: "true"
in the checkout step so that the git command can run.