小编Mic*_*oux的帖子

Powershell与Git命令错误处理

我使用Git来部署我的Web应用程序.所以在Teamcity我准备我的应用程序(编译,缩小JS和HTML,删除未使用的文件等等)然后我有一个Powershell构建步骤:

$ErrorActionPreference = "Stop"
git init
git remote add origin '%env.gitFolder%'
git fetch
git reset --mixed origin/master
git add .
git commit -m '%build.number%'
git push origin master
Run Code Online (Sandbox Code Playgroud)

但是如果抛出异常,脚本会继续(即使我设置$ErrorActionPreference = "Stop")并且构建成功.

我希望脚本在出现错误时停止,并且构建失败.

我试图进行Format stderr output as: error构建步骤Fail build if: an error message is logged by build runner,因此构建失败,但脚本继续,因此它创建了一个愚蠢的提交.

我尝试在我的脚本中添加一个try-catch,但它没有进入catch ...

有没有人有想法停止脚本并失败构建错误?

抱歉我的英语,我是法国人...... ^^

git powershell teamcity

8
推荐指数
2
解决办法
2873
查看次数

标签 统计

git ×1

powershell ×1

teamcity ×1