How to capture screenshots and log html files when we ran test from azure devops pipeline

Hi,

I couldn’t see screenshots and log html files for fail case when we run through azure devops pipeline. Is there any way we can capture those details.

Thanks,
Sudheer

You should have a step to save those logs and images as an artifact.

Hi,
You can use in your pipeline the task “Publish Build Artifacts”

See the Documentation :

Hopefully this helps for you.

Hi ,
I have used build artifacts to publish results but I could not find any results. Below is the warning it shows

##[warning]Directory ‘/Users/runner/work/1/a’ is empty. Nothing will be added to build artifact ‘MyBuildOutputs’.

Task used in YAML file:

  • task: CopyFiles@2
    inputs:
    contents: ‘_buildOutput/**’
    targetFolder: $(Build.ArtifactStagingDirectory)
  • task: PublishBuildArtifacts@1
    inputs:
    pathToPublish: $(Build.ArtifactStagingDirectory)
    artifactName: MyBuildOutputs

Thanks,
Sudheer

“Publish Pipeline Artifact” can be used…This will be visible if you’re using the classic edition of Azure Devops Pipelines.
The file directory/path of where the logs and screenshots are stored needs to be provided in this pipeline step.

@LMVarsha, Can you please share the sample format of publish pipeline artifact to capture log files and screenshot

I’ve set up devops YAML pipeline test result publishing like this:

#Publish test results after test run
- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: 'outputxunit.xml'
    searchFolder: 'C:\Temp\RobotFiles\'
    publishRunAttachments: true
  condition: succeededOrFailed()
  displayName: 'Publish Test Results'

#Copy test result files from agent machine to artifact staging directory
- task: CopyFiles@2
  inputs:
    SourceFolder: 'C:\Temp\RobotFiles\'
    targetFolder: $(Build.ArtifactStagingDirectory)
  condition: succeededOrFailed()
  displayName: Copy test result files to artifact staging directory

#Publish test results to BuildOutputs build artifact 
- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: $(Build.ArtifactStagingDirectory)
    artifactName: BuildOutputs
  condition: succeededOrFailed()
  displayName: Publish build artifacts

and after the pipeline is completed, test results can be found from BuildOutputs artifact under build artifacts.

2 Likes