{
    "id": "61F2A582-95AE-4948-B34D-A1B3C4F6A737",
    "name": "DownloadPipelineArtifact",
    "friendlyName": "Download pipeline artifact",
    "description": "Download a named artifact from a pipeline to a local path",
    "helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/download-pipeline-artifact",
    "helpMarkDown": "Download a named artifact from a pipeline to a local path",
    "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": "Download artifacts produced by",
            "defaultValue": "current",
            "required": true,
            "options": {
                "current": "Current build",
                "specific": "Specific build"
            },
            "helpMarkDown": "Download artifacts produced by the current build, or from a specific build."
        },
        {
            "name": "project",
            "type": "pickList",
            "label": "Project",
            "defaultValue": "",
            "required": true,
            "visibleRule": "buildType == specific",
            "properties": {
                "EditableOptions": "True",
                "DisableManageLink": "True"
            },
            "helpMarkDown": "The project from which to download the pipeline artifacts."
        },
        {
            "name": "definition",
            "aliases": [
                "pipeline"
            ],
            "type": "pickList",
            "label": "Build pipeline",
            "defaultValue": "",
            "required": true,
            "visibleRule": "buildType == specific",
            "properties": {
                "EditableOptions": "True",
                "DisableManageLink": "True",
                "IsSearchable": "True"
            },
            "helpMarkDown": "Select the build pipeline name."
        },
        {
            "name": "specificBuildWithTriggering",
            "type": "boolean",
            "label": "When appropriate, download artifacts from the triggering build.",
            "defaultValue": "false",
            "required": false,
            "visibleRule": "buildType == specific",
            "helpMarkDown": "If checked, this build task will try to download artifacts from the triggering build. If there is no triggering build from the specified pipeline, it will download artifacts from the build specified in the options below."
        },
        {
            "name": "buildVersionToDownload",
            "type": "pickList",
            "label": "Build version to download",
            "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": "Branch name",
            "defaultValue": "refs/heads/master",
            "visibleRule": "buildType == specific && buildVersionToDownload == latestFromBranch",
            "required": true,
            "helpMarkDown": "Specify to filter on branch/ref name, for example: ```refs/heads/develop```."
        },
        {
            "name": "buildId",
            "aliases": [
                "pipelineId"
            ],
            "type": "pickList",
            "label": "Build",
            "defaultValue": "",
            "required": true,
            "visibleRule": "buildType == specific && buildVersionToDownload == specific",
            "properties": {
                "EditableOptions": "True",
                "DisableManageLink": "True"
            },
            "helpMarkDown": "The build from which to download the artifacts."
        },
        {
            "name": "tags",
            "type": "string",
            "label": "Build Tags",
            "defaultValue": "",
            "visibleRule": "buildType == specific && buildVersionToDownload != specific",
            "required": false,
            "helpMarkDown": "A comma-delimited list of tags. Only builds with these tags will be returned."
        },
        {
            "name": "artifactName",
            "type": "pickList",
            "label": "Artifact name",
            "defaultValue": "",
            "required": false,
            "properties": {
                "EditableOptions": "True",
                "DisableManageLink": "True"
            },
            "helpMarkDown": "The name of the artifact to download."
        },
        {
            "name": "itemPattern",
            "type": "multiLine",
            "label": "Matching pattern",
            "defaultValue": "**",
            "required": false,
            "properties": {
                "rows": "3",
                "resizable": "true"
            },
            "helpMarkDown": "Specify files to be downloaded as multi line minimatch pattern. [More Information](https://aka.ms/minimatchexamples).</p>"
        },
        {
            "name": "downloadPath",
            "aliases": [
                "targetPath"
            ],
            "type": "string",
            "label": "Destination directory",
            "defaultValue": "$(System.ArtifactsDirectory)",
            "required": true,
            "helpMarkDown": "Path on the agent machine where the artifacts will be downloaded."
        }
    ],
    "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": "Download Pipeline Artifact",
    "execution": {
        "AgentPlugin": {
            "target": "Agent.Plugins.PipelineArtifact.DownloadPipelineArtifactTaskV1_1_3, Agent.Plugins"
        }
    },
    "messages": {}
}