You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Pipelines SystemsManagerRunCommand@1任务实例标签配置求助

解决Azure Pipelines SystemsManagerRunCommand@1任务的instanceTags配置问题

针对标签匹配实例的需求,instanceTags的正确格式为JSON对象:键对应标签名称,值对应标签值的数组(单个值时也可直接用字符串)。

比如你需要匹配标签example值为value1或value2的实例,配置写法如下:

instanceTags: '{"example": ["value1", "value2"]}'

如果需要同时匹配多个标签(需全部满足),可扩展JSON对象:

instanceTags: '{"Environment": ["Production"], "Role": ["WebServer", "AppServer"]}'

修改后的完整任务配置示例:

- task: SystemsManagerRunCommand@1
  displayName: "Install latest CwAgent"
  inputs:
    regionName: 'eu-central-1'
    awsCredentials: my credentials
    documentName: 'AWS-ConfigureAWSPackage'
    documentParameters: >
      {
        "action": ["Install"],
        "name": ["AmazonCloudWatchAgent"],
        "version": ["latest"]
      }
    comment: 'Install latest version of cloud watch agent on target machines'
    instanceSelector: 'fromTags'
    instanceTags: '{"example": ["value1", "value2"]}' # 替换为你的目标标签键值对
- task: SystemsManagerRunCommand@1
  displayName: "Update agent with latest config"
  inputs:
    regionName: 'eu-central-1'
    awsCredentials: my credentials
    documentName: 'AmazonCloudWatch-ManageAgent'
    documentParameters: >
      {
        "action": ["configure"],
        "mode": ["ec2"],
        "optionalConfigurationSource": ["ssm"],
        "optionalConfigurationLocation": ["/CWAgent/CustomConfiguration.json"],
        "optionalRestart": ["yes"]
      }
    comment: 'manage agent to use our custom config'
    instanceSelector: 'fromTags'
    instanceTags: '{"example": ["value1", "value2"]}' # 替换为你的目标标签键值对

注意:JSON字符串需用单引号包裹,避免与YAML的双引号语法冲突;若标签仅需匹配单个值,可简化为{"example": "value1"}。

内容的提问来源于stack exchange,提问作者Jack Hurley

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 13:45:10