【问题标题】:Azure Devops YAML: Invalid JavaScript property identifier character yamlAzure Devops YAML:无效的 JavaScript 属性标识符字符 yaml
【发布时间】:2019-07-09 17:40:22
【问题描述】:

使用 Azure DevOps YAML 任务“Invoke-HTTP”,我不断得到 Exception message 'Exception Message: Invalid JavaScript property identifier character: -. Path '', line 1, position 8. (type JsonReaderException)'

这是任务的文档:

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/http-rest-api?view=azure-devops

脚本如下: jobs: # Publish resource group artifact - job: invoke_http_for_ase pool: server continueOnError: true steps: # Invoke REST API # Invoke a REST API as a part of your pipeline. - task: InvokeRESTAPI@1 displayName: 'GET Member' inputs: connectionType: 'connectedServiceNameARM' azureServiceConnection: 'ARM-Service-Connection' method: 'GET' headers: '{Content-Type:application/json}' urlSuffix: "subscriptions/xxx/resourceGroups/xxx?api-version=2018-05-01" waitForCompletion: 'true'

设计师在发布管道中的发布任务也同样有效。

【问题讨论】:

  • 那是哪个角色?还是你不知道?
  • 我怀疑参数:azureServiceConnection,尝试不带特殊字符..

标签: azure-devops yaml


【解决方案1】:

问题在于标头值必须是有效的 JSON,即属性名称和值必须用引号引起来。见this github issue

【讨论】:

    【解决方案2】:

    缩进是你的问题。将“jobs:”下方的每一行移到左侧,即:

    jobs: - job: invoke_http_for_ase pool: server continueOnError: true steps: # Invoke REST API # Invoke a REST API as a part of your pipeline. - task: InvokeRESTAPI@1 displayName: 'GET Member' inputs: connectionType: 'connectedServiceNameARM' azureServiceConnection: 'ARM-Service-Connection' method: 'GET' headers: '{Content-Type:application/json}' urlSuffix: "subscriptions/xxx/resourceGroups/xxx?api-version=2018-05-01" waitForCompletion: 'true'

    【讨论】:

      猜你喜欢
      • 2022-01-08
      • 2022-11-14
      • 1970-01-01
      • 1970-01-01
      • 2019-10-27
      • 1970-01-01
      • 2021-11-01
      • 2021-03-25
      • 2021-10-14
      相关资源
      最近更新 更多