Apps
Apps

Reputation: 3389

Azure DevOps access the files generated using the pipeline?

I'm trying the REST APIs available in Azure DevOps. The intention of it is to trigger the test cases (angular application) programmatically. I've defined the pipeline and able to successfully invoke it using the Run API. In the pipeline definition yaml file, we have the below task

  - task: PublishTestResults@3
    displayName: 'Publish unit testing results'
    inputs:
      searchFolder: $(System.DefaultWorkingDirectory)/unit-test-reports
      testRunTitle: myngapp ui
      testResultsFormat: JUnit
      testResultsFiles: '**/TESTS*.xml' 

This checks the TESTS*.xml file to create a report.

I wanted to access these files via the API. Is it possible for me to access these files via the API?

Upvotes: 0

Views: 1053

Answers (1)

Bowman Zhu
Bowman Zhu

Reputation: 7241

You can first archive the files and then publish the build artifact.

pool:
  vmImage: ubuntu-latest

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'
  
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.BinariesDirectory)'
    includeRootFolder: true
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

After that, you should be able to use this REST API to get the files:

https://learn.microsoft.com/en-us/rest/api/azure/devops/build/artifacts/get?view=azure-devops-rest-4.1

Upvotes: 1

Related Questions