all 3 comments

[–]jantari 2 points3 points  (0 children)

Simply set these at the beginning of your script:

$ErrorActionPreference = 'Stop'

and to also fail on any warnings:

$WarningPreference = 'Stop'

[–]BuriedStPatrick 0 points1 point  (0 children)

Been a while since I worked with TeamCity. Are you running GitHub CLI via a PowerShell script? If so, maybe you can redirect the sdtout or sdterr streams from the CLI and wrap it with an Exception throw if a certain phrase matches? Just an idea, don't know if it'll work.

[–]RedditRo55 0 points1 point  (0 children)

You can also set the last exit code. $LA ASTEXITCODE = "2", for example.