Why are my PowerShell exit codes always “0”?

前端 未结 5 1223
死守一世寂寞
死守一世寂寞 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:50

    I was having this exact issue while running with the -file, but for some reason the trap syntax or the 'exit' syntax provided by Kevin wasn't working in my scenario.

    I am not sure why, but just in case somebody else hits the same problem, I used the below syntax and it worked for me:

    try{
        #DO SOMETHING HERE
    }
    catch
    {
        Write-Error $_
        ##teamcity[buildStatus status='FAILURE']
        [System.Environment]::Exit(1)
    }
    

提交回复
热议问题