0

I got an Azure yaml pipeline in which there is this step:

- task: QueryAzureDevOpsExtensionVersion@3
        displayName: 'Query Extension Version'
        inputs:
          connectTo: 'VsTeam'
          connectedServiceName: 'Marketplace-Admin'
          publisherId: '$(publisherId)'
          extensionId: '$(extensionId)'
          versionAction: 'Patch'
          outputVariable: 'Task.Extension.Version'
          cwd: '$(Build.SourcesDirectory)/AzurePipelinesTasks'

This step returns the error

##[error]SyntaxError: Unexpected end of JSON input

As far as I know, this error means that a user is trying to parse a response in a wrong way or there might not even be a response, but this is just an already made pipeline step.

How can I fix this issue?

EDIT: this is the output:

##[debug]Evaluating condition for step:

'Query Extension Version'
##[debug]Evaluating: SucceededNode()
##[debug]Evaluating SucceededNode:
##[debug]=> True
##[debug]Result: True
##[section]Starting: Query Extension Version ==============================================================================
Task         : Query Extension Version
Description  : Queries the current version from the Visual Studio Marketplace
Version      : 3.1.119
Author       : Microsoft Corporation
Help         :
  ==============================================================================
##[debug]Using node path: /home/vsts/agents/2.209.0/externals/node10/bin/node
##[debug]agent.TempDirectory=/home/vsts/work/_temp
##[debug]loading inputs and endpoints
##[debug]loading INPUT_CONNECTTO
##[debug]loading INPUT_CONNECTEDSERVICENAME
##[debug]loading INPUT_PUBLISHERID
##[debug]loading INPUT_EXTENSIONID
##[debug]loading INPUT_VERSIONACTION
##[debug]loading INPUT_OUTPUTVARIABLE
##[debug]loading INPUT_SETBUILDNUMBER
##[debug]loading INPUT_EXTENSIONVERSIONOVERRIDE
##[debug]loading INPUT_CWD
##[debug]loading ENDPOINT_AUTH_a6d7d10f-44f1-4c21-8e52-1d28bce44589
##[debug]loading ENDPOINT_AUTH_SCHEME_a6d7d10f-44f1-4c21-8e52-1d28bce44589
##[debug]loading ENDPOINT_AUTH_PARAMETER_a6d7d10f-44f1-4c21-8e52-1d28bce44589_PASSWORD
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loaded 16
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined ##[debug]extensionVersionOverride=Extension.VersionOverride
##[debug]Override variable specified checking for value.
##[debug]Extension.VersionOverride=undefined
##[debug]__tfxpath=/opt/hostedtoolcache/tfx/0.7.11/x64/bin
##[debug]which '/opt/hostedtoolcache/tfx/0.7.11/x64/bin/tfx'
##[debug]found: '/opt/hostedtoolcache/tfx/0.7.11/x64/bin/tfx'
##[debug]using: /opt/hostedtoolcache/tfx/0.7.11/x64/bin/tfx
##[debug]which '/opt/hostedtoolcache/tfx/0.7.11/x64/bin/tfx'
##[debug]found: '/opt/hostedtoolcache/tfx/0.7.11/x64/bin/tfx'
##[debug]cwd=/home/vsts/work/1/s
##[debug]connectTo=VsTeam
##[debug]connectedServiceName=a6d7d10f-44f1-4c21-8e52-1d28bce44589
##[debug]a6d7d10f-44f1-4c21-8e52-1d28bce44589=https://marketplace.visualstudio.com/
##[debug]a6d7d10f-44f1-4c21-8e52-1d28bce44589 exists true
##[debug]rootFolder=undefined
##[debug]patternManifest=undefined
##[debug]localizationRoot=undefined
##[debug]extensionTag=undefined
##[debug]method=undefined
##[debug]fileType=undefined
##[debug]extensionName=undefined
##[debug]extensionVisibility=undefined
##[debug]extensionPricing=undefined
##[debug]extensionVersion=undefined
##[debug]noWaitValidation=undefined
##[debug]bypassLocalValidation=undefined
##[debug]arguments=undefined
##[debug]versionAction=Patch
(node:1810) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency 0 [ '(node:1810) Warning: Accessing non-existent property \'padLevels\' of module exports inside circular dependency',
  '(Use `node --trace-warnings ...` to show where the warning was created)',
  '' ]
(Use `node --trace-warnings ...` to show where the warning was created) 1 [ '(node:1810) Warning: Accessing non-existent property \'padLevels\' of module exports inside circular dependency',
  '(Use `node --trace-warnings ...` to show where the warning was created)',
  '' ]
 2 [ '(node:1810) Warning: Accessing non-existent property \'padLevels\' of module exports inside circular dependency',
 '(Use `node --trace-warnings ...` to show where the warning was created)',
  '' ]
null 0 [ 'null', '' ]
 1 [ 'null', '' ]
##[debug]task result: Failed
##[error]SyntaxError: Unexpected end of JSON input
##[debug]Processed: ##vso[task.issue type=error;]SyntaxError: Unexpected end of JSON input
##[debug]Processed: ##vso[task.complete result=Failed;]SyntaxError: Unexpected end of JSON input
##[section]Finishing: Query Extension Version
CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
  • Turn on debug/diagnostics for your pipeline, look at the error message returned by TFX. I suspect it can't find the extension and isn't giving a better error message. Without debug log I can't say anything about the reason. – jessehouwing Sep 04 '22 at 12:19
  • @jessehouwing I checked the enable diagnotstics box and added the output of the task. Hope its what you were looking for to see – CodeMonkey Sep 04 '22 at 14:44
  • by the way, the pipeline is simply this one from the documentation: https://learn.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=azure-devops – CodeMonkey Sep 04 '22 at 14:55
  • Looks like TFX returned null, I suspect there is no existing version published on the marketplace. There is an override variable you can provide for special cases like this. – jessehouwing Sep 04 '22 at 14:56
  • What do you mean that no existing version is published if it got the input of the extension id? And if I use the override variable it will take the same version every run instead of increasing it – CodeMonkey Sep 04 '22 at 15:04
  • ExtensionId should NOT be a guid... And TFX should be at 0.12.x, instead of 0.7.x. I'm guessing there are more issues here... – jessehouwing Sep 04 '22 at 15:15
  • @jessehouwing I think the documentation from MS in that link I provided is kinda lacking... I hope they update it since its missing alot – CodeMonkey Sep 04 '22 at 15:20
  • Send 'm a pull request. There are many ways to run 9our pipeline. Mine to publish the Azure pipelines extension tasks is very different. You probably don't even need to specify the publisher and extensionId in this case, since they should be in the vss-extension.jsin anyway. – jessehouwing Sep 04 '22 at 20:55
  • 1
    Check out these examples for your inspiration: https://github.com/microsoft/azure-devops-extension-tasks/blob/main/azure-pipelines.yml and https://github.com/jessehouwing/azure-pipelines-variable-tasks/blob/main/azure-pipelines.yml and https://github.com/jessehouwing/azure-pipelines-gate-condition-editor/blob/main/azure-pipelines.yml – jessehouwing Sep 04 '22 at 20:58
  • And checkout this related answer: https://stackoverflow.com/a/56029399/736079 – jessehouwing Sep 04 '22 at 21:03
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/247779/discussion-between-jessehouwing-and-yonatan-nir). – jessehouwing Sep 04 '22 at 21:09
  • I was wondering what would happen if I choose to increase a major instead of a patch.. with the example from MS's documentation it means I need to run the pipeline manually with a different choice but with your examples I can just update the vss-extension file and it will take the version from there? – CodeMonkey Sep 05 '22 at 06:57
  • Yups. The query version task is useful in some cases. And I've used it in the past, but I've resorted to using the build number as patch version and manage the major/minor version in the manifest files. – jessehouwing Sep 05 '22 at 07:06
  • and is it possible with your example to let it behave in a manner such that if no version was changed in the manifest compared to the version in the market place then increase patch and also update the extension file, but if a version was changed in the extension file then just take what is there? – CodeMonkey Sep 05 '22 at 07:12
  • No, don't think so... But you could easily script that in 20 lines of powershell. – jessehouwing Sep 05 '22 at 10:48
  • These are great separate questions. – jessehouwing Sep 05 '22 at 10:49
  • 1
    I did something similar here, querying the version from the json file directly, you could then run Query Extension Version and then compare the 2 values and set the value to your desired value. In the end the Package/Publish task just takes a value you pass in, that value can come from any source. https://github.com/jessehouwing/jessehouwingnl-Casper/blob/64bb1a159bf8663ace718fd9ee39e0ac462ca81b/azure-pipelines.yml#L10 – jessehouwing Sep 05 '22 at 10:54

1 Answers1

0

It looks like TFX returned null, meaning the extension doesn't exist yet and it can't query the version. in that case the task should fail.

Check that the extension id you provided as an input is the one from the vss extension file and NOT the one from task.json file.

There is a way to provide an override variable for cases like this (or when you want to bump the major version number):

- task: ms-devlabs.vsts-developer-tools-build-tasks.extension-version-build-task.QueryAzureDevOpsExtensionVersion@3
  displayName: 'Query Extension Version: jessehouwing.$(ExtensionId)'
  inputs:
    connectedServiceName: 'Jesse Houwing'
    publisherId: jessehouwing
    extensionId: '$(ExtensionId)'
    extensionVersionOverride: Extension.VersionOverride

Then make sure you have a Settable at queuetime variable called Extension.VersionOverride.

Create variable settable at queue time

When queueing your very first run, override the version and set it to whatever the very first version should be, e.g. 1.0.0:

How to set queue time variable

This should use the override and ignore the version on the marketplace (or the lack thereof) for this run and this run only.

If you later want to increase the version to say 2.0.0, you can use the same override to have it skip to the next major version.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • 1
    I actually figured it out from the last comment I wrote you with the id as an input. It seemed like the input for the id was the id saved in the task.json while it should have been given the id that is saved in the vss extension file (which is why it returned null like you said). When changing it, the step passed – CodeMonkey Sep 04 '22 at 15:15