Why are my PowerShell exit codes always “0”?

前端 未结 5 1221
死守一世寂寞
死守一世寂寞 2020-12-04 14:59

I\'ve got a PowerShell script as follows

##teamcity[progressMessage \'Beginning build\']
# If the build computer is not running the appropriate version of .N         


        
5条回答
  •  南笙
    南笙 (楼主)
    2020-12-04 15:54

    Until this (presumably) gets closed as dup of my self-answer of an older question, I'll summarise the cleanest solution here:

    • Most of the other answers involve emitting something to the stderr from the PowerShell bit. This can be accomplished directly with TeamCity via the Format stderr output as option (set it to Error instead of the default, which is Warning)

    • However, critically, it's also necessary to switch on the "Fail build if: ... An error message is logged by (sic) build runner" under "Failure Conditions" (if any of the other answers work for you, you'll likely have this switched on already but IME it's very easy to forget!)

提交回复
热议问题