Skip to content

Commit

Permalink
[devops] Append to the agent log, instead of creating the file.
Browse files Browse the repository at this point in the history
Append to the agent log, instead of creating the file, when an exception occcurs.

The problem is that creating the file fails if it already exists:

    Exception occurred: Exception calling "Parse" with "1" argument(s): "String '' was not recognized as a valid DateTime."
    New-Item: /Users/builder/azdo/_work/4/s/xamarin-macios/tools/devops/automation/scripts/generate_agent_logs.ps1:52
    Line |
      52 |      New-Item -Path $Output -Value "$_"
         |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         | The file '/Users/builder/azdo/_work/4/s/agent-logs.log' already exists.
  • Loading branch information
rolfbjarne committed Sep 20, 2024
1 parent 7371986 commit d2c1924
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tools/devops/automation/scripts/generate_agent_logs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ try {
log show --predicate $Predicate --style $Style --start "$start" --end "$end" > $Output
}
} catch {
Write-Host "Exception occurred: $_"
# Create the output file, because we later try to upload it as an artifact, and *not* uploading
# if there's *no* file is much harder than just creating the file.
New-Item -Path $Output -Value "$_"
Write-Host "Exception occurred: $_" | Tee-Object -FilePath $Output -Append
}

0 comments on commit d2c1924

Please sign in to comment.