Home > Back-end >  How to move build artifact into current working directory
How to move build artifact into current working directory

Time:05-16

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?

CodePudding user response:

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

So:

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

CodePudding user response:

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'
  • Related