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
CodePudding user response:
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
.
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
:
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.