在完成“下载管道工件”任务之前将工件删除

时间:2020-10-19 04:22:22

标签: azure azure-devops

我创建了一个管道来从另一个管道下载最新的工件,然后它们列出了存档。这是我的YAML:

trigger: none

jobs:
  - job:  DownloadLeaf
    timeoutInMinutes: 180
    pool:
      vmImage: 'vs2017-win2016'

    steps:
      
      - task: DownloadPipelineArtifact@2
        inputs:
          source: 'specific'
          project: 'Leaf'
          pipeline: 'Leaf'
          runVersion: 'latest'
          branchName: 'refs/heads/develop'
          allowPartiallySucceededBuilds: true
          patterns: '**.exe'
          downloadPath: $(Pipeline.Workspace)
          
      - task: CmdLine@2
        inputs:
              script: |
                cd $(Pipeline.Workspace)
                dir 

显然,下载工作正常,但是在完成下载管道工件任务之前删除了工件。有办法避免这种情况吗?我需要列出并安装此下载的工件。

原始日志:

2020-10-19T03:59:22.4539300Z ##[debug]Evaluating condition for step: 'DownloadPipelineArtifact'
2020-10-19T03:59:22.4541936Z ##[debug]Evaluating: SucceededNode()
2020-10-19T03:59:22.4542546Z ##[debug]Evaluating SucceededNode:
2020-10-19T03:59:22.4543934Z ##[debug]=> True
2020-10-19T03:59:22.4544517Z ##[debug]Result: True
2020-10-19T03:59:22.4545085Z ##[section]Starting: DownloadPipelineArtifact
2020-10-19T03:59:22.4762712Z ==============================================================================
2020-10-19T03:59:22.4763081Z Task         : Download Pipeline Artifacts
2020-10-19T03:59:22.4763399Z Description  : Download build and pipeline artifacts
2020-10-19T03:59:22.4763642Z Version      : 2.3.1
2020-10-19T03:59:22.4763894Z Author       : Microsoft Corporation
2020-10-19T03:59:22.4764254Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/download-pipeline-artifact
2020-10-19T03:59:22.4764685Z ==============================================================================
2020-10-19T03:59:23.7655864Z Download from the specified build: #197
2020-10-19T03:59:23.7680832Z ##[debug]Processed: ##vso[task.setvariable variable=BuildNumber;issecret=False;]197
2020-10-19T03:59:23.7681693Z Download artifact to: D:\a\1
2020-10-19T03:59:23.9065283Z ##[warning]Please use Download Build Artifact task for downloading Build Artifact type artifact. https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/download-build-artifacts?view=azure-devops
2020-10-19T03:59:23.9453572Z ##[debug]Processed: ##vso[task.logissue type=warning;]Please use Download Build Artifact task for downloading Build Artifact type artifact. https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/download-build-artifacts?view=azure-devops
2020-10-19T03:59:24.0583745Z Information, Start downloading FCS artifact- TestBuild-Leaf-20201013.3
2020-10-19T03:59:24.0584657Z Information, Minimatch patterns: [**.exe]
2020-10-19T03:59:24.0906614Z Information, Item excluded: TestBuild-Leaf-20201013.3
2020-10-19T03:59:24.0907588Z Information, Item excluded: TestBuild-Leaf-20201013.3/leaf-TestBuild20201013.3-setup.exe
2020-10-19T03:59:24.1072367Z Downloading artifact finished.
2020-10-19T03:59:24.1236846Z ##[section]Finishing: DownloadPipelineArtifact

1 个答案:

答案 0 :(得分:0)

工件没有在管道中删除。它只是没有下载。您在任务中指定的模式**.exe 不正确,导致没有找到匹配的文件,也没有下载任何文件。

如果要在工件中下载.exe文件。您可以指定类似**/*.exe的模式。有关更多信息,请参见Pattern syntax。参见下面的修改后的Yaml:

 - task: DownloadPipelineArtifact@2
        inputs:
          source: 'specific'
          project: 'Leaf'
          pipeline: 'Leaf'
          runVersion: 'latest'
          branchName: 'refs/heads/develop'
          allowPartiallySucceededBuilds: true
          patterns: '**/*.exe'
          downloadPath: $(Pipeline.Workspace)

工件将被下载到artifactName downloadPath中指定路径下的子文件夹ie. $(Pipeline.Workspace)/artifactName中。您可以CD到文件夹$(Pipeline.Workspace)/artifactName列出内容

 - task: CmdLine@2
        inputs:
              script: |
                cd $(Pipeline.Workspace)/TestBuild-Leaf-20201013.3
                dir 

并且在任务中被警告。您可以使用Download Build Artifact任务而不是Download pipeline Artifact

来摆脱警告消息

## [警告]请使用Download Build Artifact任务来下载Build Artifact类型工件