【问题标题】:How to copy files from multiple folders on Azure DevOps CI?如何从 Azure DevOps CI 上的多个文件夹复制文件?
【发布时间】:2018-11-05 23:05:21
【问题描述】:

在 Azure DevOps CI 的 yaml 配置文件中,我有一个 CopyFiles@2 任务,以便为 PublishBuildArtifacts 暂存文件。我想 (1) 从源目录的根目录复制特定文件,以及 (2) 从特定文件夹复制所有文件。我可以成功复制特定文件,但是当我为特定文件夹添加行时,它会失败。这是yaml sn-p:

- task: CopyFiles@2 inputs: sourceFolder: $(Build.SourcesDirectory) contents: ?(binclash.log|init-tools.log) logs/**/* targetFolder: $(Build.ArtifactStagingDirectory)

源的文件夹树如下所示: <repo root> `-- binclash.log `-- init-tools.log `-- logs |-- debug `-- release `-- src `-- ml.cs

如所列,这会报告找到零个文件。然而, 如果我删除logs/**/*,那么它会成功找到并复制 binclash.log 和 init-tools.log。是否有一些与我缺少的引号或换行符相关的语法?

【问题讨论】:

  • 你能分享你的文件夹树和构建日志吗?
  • 这是一个调试设置为 true 的日志:dnceng.visualstudio.com/public/_build/… 对于这次运行,yaml 是:``` 内容:msbuild.* binclash.log init-tools.log ``` 和文件夹树看起来像:``` -- src |--ml.cs -- msbuild.log -- binclash.log -- init-tools.log
  • 我上面试图描述的是在“内容”下有多行。每当我尝试这样做时,都会发现要复制的文件为零(成功状态)。我目前的解决方法是在“内容”下为我想要的每一行设置单独的任务。
  • 你的源文件夹树是什么?

标签: azure-devops


【解决方案1】:

我有一个非常相似的问题,我想使用一个特定的文件夹作为我的构建工件。

当您直接定位文件夹时:logs/**/*,它返回 0 个结果。

尝试使用**/logs/**

我在下面更新了你的 sn-p:

- task: CopyFiles@2
  inputs:
    sourceFolder: $(Build.SourcesDirectory)
    contents:
      ?(binclash.log|init-tools.log)
      **/logs/**
    targetFolder: $(Build.ArtifactStagingDirectory)

当我查看您的代码时,我注意到您可以简化为:

- task: CopyFiles@2
  inputs:
    contents: '**/logs/**/?(binclash.log|init-tools.log)'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-02
    • 2018-08-06
    • 2021-08-12
    • 1970-01-01
    • 2022-08-04
    • 1970-01-01
    • 2022-11-11
    • 2019-09-01
    相关资源
    最近更新 更多