Ashutosh Mehar
Ashutosh Mehar

Reputation: 11

Is it possible to copy output file of one task to be and access from next task in the Azure pipeline?

I have an azure pipeline with one of the task running the performance test and output the result in json file. I want to copy the Json file in another task where I am calling .Net unit test code to compare the key-value with expected json file. I am able to copy the file into some folder may it be custom folder
like TargetFolder: '$(Build.BinariesDirectory)/testfolder' or in $(Build.BinariesDirectory) . The file gets copied sussessfully.

But I am not able to read the file from the location where it gets copied for my next unit test task.

Is it possible to do ?

Upvotes: 0

Views: 960

Answers (1)

Shamrai Aleksander
Shamrai Aleksander

Reputation: 15998

Yes, you can read files in any task of your build. As example:

pool:
  name: Azure Pipelines

steps:
- script: |
   @echo off   
   echo Write your commands here> test.txt   
   echo Hello world>> test.txt   
  displayName: 'Command Line Script'

- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: .
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

- script: 'type $(Build.ArtifactStagingDirectory)\test.txt'
  displayName: 'Command Line Script'

The result:

enter image description here

Upvotes: 1

Related Questions