Search code examples
azuretfsazure-devopsazure-devops-pipelines

azure devops pipeline CopyFiles@2 task copy's files from agent A but DownloadBuildArtifacts@0 downloads the files to agent B


i have wired behavior with the copy files from hosted agent and then downloading them back to the same agent looks like it copies the files from agent A but the same pipeline downloading them back to Agent B with is in another machine doing another build job that is not related

Upload from ios_docker_142_linux_slave_1 enter image description here

Download back to different agent ios_docker_141_linux_slave_3 , why ? enter image description here

 - task: CopyFiles@2
    inputs:
      CleanTargetFolder: 'true'
      SourceFolder: '$(Agent.HomeDirectory)/../${{parameters.Folderpath}}'
      Contents: '**'
      TargetFolder: '$(build.artifactstagingdirectory)'

Solution

  • This is an expected behavior if you are using parallel jobs. According to your screenshot, there are multiple jobs self-hosted connect , mac_agent, copy_back_files_to_self..

    One agent one job at a time. If the agent is running a job, it will in busy status, and other jobs will look for idle agents to run . The parallel jobs is for running multiple jobs in multiple agents at a time.

    To achieve what you want, you need to specify detail agent in your YAML file. The pool name needs to add to the name field, then you could add demands. You may try the following YAML Code:

    stages:
    
    - stage: Deploy
    
      pool: 
    
       name: AgentPoolName(e.g. alm-aws-pool)
    
       demands:
    
        - agent.name -equals Agentname (e.g. deploy-05-agent1)
    
      jobs:
    
      - job: BuildJob
    
        steps:
    
        - script: echo Building!