azure - 如何在azure devops api服务中传递具有多个值的对象参数

标签 azure azure-devops azure-pipelines devops

我正在尝试使用 azure-devops-rest-6.0 运行带有对象参数的管道

- name: images
  displayName: docker images
  type: object
  default:
  - image1
  - image2
  - image3

但是每次我在发布请求正文中传递此模板参数时,我都会得到 Expected aequence or mapping。实际值“image1””

    "templateParameters": {
        "images": "image1"
    }

所以我尝试用数组类型替换它,但它会抛出错误,例如必须提供参数。对于我确定我为所有字段提供了值的所有字段。

    "templateParameters": {
        "images": ["image1"]
    }

我在传递值时错过了什么错误吗?正确的做法是什么?

最佳答案

根据您的 YAML 示例和请求正文,您需要修改请求正文中的格式。

您可以使用以下格式:

  "templateParameters": {
    "images": "[image1,image2]"
   }

完整示例:

{
  "resources": {
    "repositories": {
      "self": {
        "refName": "refs/heads/main"
      }
    }
  },
  "templateParameters": {
    "images": "[image1,image2]"
   }


}

关于azure - 如何在azure devops api服务中传递具有多个值的对象参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72554007/

相关文章:

node.js - 使用nodejs从Azure Keyvault获取Secret

azure - 通过 Azure CLI 登录帐户失败

azure - 无法解析远程名称 : 'dev.azure.com' when setting up self-hosted devops agent in Docker

azure - 在不同环境之间移动突触工作空间的不同选项

azure - 通过 DevOps Pipeline 将 Docker 镜像上传到 ACR

azure - 如何在最新的azure webjob 3.03中指定AzureWebJobsStorage

c# - 获取 Azure WebApp 上的 ASP.NET 类库项目中的文件路径

visual-studio-2010 - 在没有团队基础服务器的情况下运行 Mstest.exe。

azure - npm 任务未在 Azure 管道中创建 node_modules 文件夹

azure - AZ REST DevOps 方法返回 "az : Not a json response"