{
  "id": "61F2A582-95AE-4948-B34D-A1B3C4F6A737",
  "name": "DownloadPipelineArtifact",
  "friendlyName": "ms-resource:loc.friendlyName",
  "description": "ms-resource:loc.description",
  "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/download-pipeline-artifact",
  "helpMarkDown": "ms-resource:loc.helpMarkDown",
  "category": "Utility",
  "author": "Microsoft Corporation",
  "version": {
    "Major": 1,
    "Minor": 230,
    "Patch": 0
  },
  "groups": [],
  "demands": [],
  "minimumAgentVersion": "2.155.1",
  "preview": false,
  "inputs": [
    {
      "name": "buildType",
      "type": "radio",
      "label": "ms-resource:loc.input.label.buildType",
      "defaultValue": "current",
      "required": true,
      "options": {
        "current": "Current build",
        "specific": "Specific build"
      },
      "helpMarkDown": "ms-resource:loc.input.help.buildType"
    },
    {
      "name": "project",
      "type": "pickList",
      "label": "ms-resource:loc.input.label.project",
      "defaultValue": "",
      "required": true,
      "visibleRule": "buildType == specific",
      "properties": {
        "EditableOptions": "True",
        "DisableManageLink": "True"
      },
      "helpMarkDown": "ms-resource:loc.input.help.project"
    },
    {
      "name": "definition",
      "aliases": [
        "pipeline"
      ],
      "type": "pickList",
      "label": "ms-resource:loc.input.label.definition",
      "defaultValue": "",
      "required": true,
      "visibleRule": "buildType == specific",
      "properties": {
        "EditableOptions": "True",
        "DisableManageLink": "True",
        "IsSearchable": "True"
      },
      "helpMarkDown": "ms-resource:loc.input.help.definition"
    },
    {
      "name": "specificBuildWithTriggering",
      "type": "boolean",
      "label": "ms-resource:loc.input.label.specificBuildWithTriggering",
      "defaultValue": "false",
      "required": false,
      "visibleRule": "buildType == specific",
      "helpMarkDown": "ms-resource:loc.input.help.specificBuildWithTriggering"
    },
    {
      "name": "buildVersionToDownload",
      "type": "pickList",
      "label": "ms-resource:loc.input.label.buildVersionToDownload",
      "defaultValue": "latest",
      "visibleRule": "buildType == specific",
      "required": true,
      "options": {
        "latest": "Latest",
        "latestFromBranch": "Latest from specific branch and specified Build Tags",
        "specific": "Specific version"
      }
    },
    {
      "name": "branchName",
      "type": "string",
      "label": "ms-resource:loc.input.label.branchName",
      "defaultValue": "refs/heads/master",
      "visibleRule": "buildType == specific && buildVersionToDownload == latestFromBranch",
      "required": true,
      "helpMarkDown": "ms-resource:loc.input.help.branchName"
    },
    {
      "name": "buildId",
      "aliases": [
        "pipelineId"
      ],
      "type": "pickList",
      "label": "ms-resource:loc.input.label.buildId",
      "defaultValue": "",
      "required": true,
      "visibleRule": "buildType == specific && buildVersionToDownload == specific",
      "properties": {
        "EditableOptions": "True",
        "DisableManageLink": "True"
      },
      "helpMarkDown": "ms-resource:loc.input.help.buildId"
    },
    {
      "name": "tags",
      "type": "string",
      "label": "ms-resource:loc.input.label.tags",
      "defaultValue": "",
      "visibleRule": "buildType == specific && buildVersionToDownload != specific",
      "required": false,
      "helpMarkDown": "ms-resource:loc.input.help.tags"
    },
    {
      "name": "artifactName",
      "type": "pickList",
      "label": "ms-resource:loc.input.label.artifactName",
      "defaultValue": "",
      "required": false,
      "properties": {
        "EditableOptions": "True",
        "DisableManageLink": "True"
      },
      "helpMarkDown": "ms-resource:loc.input.help.artifactName"
    },
    {
      "name": "itemPattern",
      "type": "multiLine",
      "label": "ms-resource:loc.input.label.itemPattern",
      "defaultValue": "**",
      "required": false,
      "properties": {
        "rows": "3",
        "resizable": "true"
      },
      "helpMarkDown": "ms-resource:loc.input.help.itemPattern"
    },
    {
      "name": "downloadPath",
      "aliases": [
        "targetPath"
      ],
      "type": "string",
      "label": "ms-resource:loc.input.label.downloadPath",
      "defaultValue": "$(System.ArtifactsDirectory)",
      "required": true,
      "helpMarkDown": "ms-resource:loc.input.help.downloadPath"
    }
  ],
  "dataSourceBindings": [
    {
      "endpointId": "tfs:teamfoundation",
      "target": "project",
      "endpointUrl": "{{endpoint.url}}/_apis/projects?$skip={{skip}}&$top=1000",
      "resultSelector": "jsonpath:$.value[?(@.state=='wellFormed')]",
      "resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{name}}}\" }",
      "callbackContextTemplate": "{\"skip\": \"{{add skip 1000}}\"}",
      "callbackRequiredTemplate": "{{isEqualNumber result.count 1000}}",
      "initialContextTemplate": "{\"skip\": \"0\"}"
    },
    {
      "endpointId": "tfs:teamfoundation",
      "target": "definition",
      "endpointUrl": "{{endpoint.url}}/{{project}}/_apis/build/definitions?api-version=3.0-preview&$top=500&continuationToken={{{continuationToken}}}&name=*{{name}}*&queryOrder=2",
      "resultSelector": "jsonpath:$.value[?(@.quality=='definition')]",
      "parameters": {
        "project": "$(project)",
        "name": "$(name)"
      },
      "resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{name}}}\" }",
      "callbackContextTemplate": "{\"continuationToken\" : \"{{{headers.x-ms-continuationtoken}}}\"}",
      "callbackRequiredTemplate": "{{{#headers.x-ms-continuationtoken}}}true{{{/headers.x-ms-continuationtoken}}}",
      "initialContextTemplate": "{\"continuationToken\" : \"{{{system.utcNow}}}\"}"
    },
    {
      "endpointId": "tfs:teamfoundation",
      "target": "buildId",
      "endpointUrl": "{{endpoint.url}}/{{project}}/_apis/build/builds?definitions={{definition}}&resultFilter=succeeded,partiallySucceeded&$top=200",
      "resultSelector": "jsonpath:$.value[*]",
      "parameters": {
        "project": "$(project)",
        "definition": "$(definition)"
      },
      "resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{buildNumber}}}\" }"
    },
    {
      "endpointId": "tfs:teamfoundation",
      "target": "artifactName",
      "endpointUrl": "{{endpoint.url}}/{{project}}/_apis/build/builds/{{buildId}}/artifacts",
      "resultSelector": "jsonpath:$.value[*]",
      "parameters": {
        "project": "$(project)",
        "buildId": "$(buildId)"
      },
      "resultTemplate": "{ \"Value\" : \"{{{name}}}\", \"DisplayValue\" : \"{{{name}}}\" }"
    }
  ],
  "instanceNameFormat": "ms-resource:loc.instanceNameFormat",
  "execution": {
    "AgentPlugin": {
      "target": "Agent.Plugins.PipelineArtifact.DownloadPipelineArtifactTaskV1_1_3, Agent.Plugins"
    }
  },
  "messages": {}
}