如何将构建工件转移到当前的工作目录中

发布于 2025-01-29 04:06:55 字数 626 浏览 4 评论 0原文

我正在尝试找到一种方法,将所有文件从我的伪影文件夹复制到$(System.DefaultWorkingDirectory)

现在,我只能使用日志中的绝对路径将其移动,但您必须同意它不是最清洁的方法。

- task: CopyFiles@2
  inputs:
     SourceFolder: '/home/vsts/work/1/BuildPipeline/drop/'
     Contents: '**'
     TargetFolder: '$(System.DefaultWorkingDirectory)'

我尝试使用$(System.ArtifactSdirectory)变量,但是当我使用它时,我最终会使用/home/vsts/work/work/1/a 。

您能推荐一种更好的方法吗?

I'm trying to find a way how to copy all the files from my artifact folder to $(System.DefaultWorkingDirectory).

enter image description here

right now i was only able to move it using absolute path from the logs but you must agree its not the cleanest way to do it.

- task: CopyFiles@2
  inputs:
     SourceFolder: '/home/vsts/work/1/BuildPipeline/drop/'
     Contents: '**'
     TargetFolder: '$(System.DefaultWorkingDirectory)'

I tried to use $(System.ArtifactsDirectory) variable but when I use it I end up on /home/vsts/work/1/a.

can you recommend a better way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

电影里的梦 2025-02-05 04:06:55

您可以使用Agent.buildDirectory指向:/home/vsts/work/1

所以:

SourceFolder: '$(Agent.BuildDirectory)/BuildPipeline/drop/'

You can use the Agent.BuildDirectory which point to: /home/vsts/work/1.

So:

SourceFolder: '$(Agent.BuildDirectory)/BuildPipeline/drop/'
英雄似剑 2025-02-05 04:06:55

您可以使用PowerShell任务递归复制文件:

  - task: PowerShell@2
    displayName: copy items to current working directory
    inputs:
      targetType: 'inline'
      script: 'Copy-Item -Path "$(System.ArtifactsDirectory)\$(Build.DefinitionName)\drop\*" -Destination "$(System.DefaultWorkingDirectory)" -Recurse'

You can use a powershell task to copy recursively the files:

  - task: PowerShell@2
    displayName: copy items to current working directory
    inputs:
      targetType: 'inline'
      script: 'Copy-Item -Path "$(System.ArtifactsDirectory)\$(Build.DefinitionName)\drop\*" -Destination "$(System.DefaultWorkingDirectory)" -Recurse'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文