question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] SyntaxError: Unexpected end of JSON input

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
humberto-fanateecommented, Sep 14, 2022

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.

1reaction
SphenicPaulcommented, Sep 11, 2022

Thanks @asbjornu - that link and solution has been able to resolve/workaround the problem I was hitting.

Much appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught SyntaxError: Unexpected end of JSON input at ...
I need some help with this error: Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse () at Object.success (dashboard.js:22) at ...
Read more >
Fix the unexpected end of input error in JavaScript
Another common cause of this error is that the JSON data is not valid for the particular structure you are trying to parse...
Read more >
Uncaught SyntaxError: Unexpected end of JSON input
This is usually observed when the coder is trying to convert a string into a JSON Object. We will try to understand the...
Read more >
Unexpected end of JSON input Error in JavaScript [Solved]
The "Unexpected end of JSON input" error occurs when trying to parse invalid JSON using the JSON.parse or $.parseJSON methods. Trying to parse...
Read more >
SyntaxError: Unexpected end of JSON input in JavaScript ...
The "Uncaught SyntaxError: Unexpected end of JSON input" is a Syntax error usually raised when parsing empty or malformed JSON data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found