我需要在Windows环境下运行一个python脚本,使用powershell作为选项,因为我的Bamboo Env只会调用它。
我需要powershell脚本,它将调用python脚本,如果python返回状态为1,则应该失败。我无法这样做,请你在这里帮助我。
检查$LASTEXITCODE
automatic variable。
$ LASTEXITCODE
包含已运行的最后一个基于Windows的程序的退出代码。
一个示例Powershell脚本(应用.
Dot sourcing operator来运行python脚本):
. py SomePythonScript.py
if ( $LASTEXITCODE -ne 0 ) {
Write-Warning "Exiting with code $LASTEXITCODE"
exit $LASTEXITCODE
}
### sample Powershell script continues here on `$LASTEXITCODE -eq 0` condition