【发布时间】:2017-10-23 04:33:31
【问题描述】:
我正在尝试为 Bitbucket 设置提交后挂钩以在我的存储库中有任何更改时触发 Teamcity。
下面是它的shell脚本:
SERVER=https://buildserver-url
USER=buildserver-user
PASS="<password>"
LOCATOR=$1
# The following is one-line:
(sleep 10; curl --user $USER:$PASS -X POST "$SERVER/app/rest/vcs-root-instances/commitHookNotification?locator=$LOCATOR" -o /dev/null) >/dev/null 2>&1 <&1 &
exit 0
但是,我在 Windows 环境中工作,需要在 Powershell 中使用此脚本,我尝试将其转换为 Powershell,但它似乎不起作用。
$SERVER=https://buildserver-url
$USER=buildserver-user
$PASS="<password>"
$LOCATOR=%1%
# The following is one-line:
(sleep 10; curl --user $USER:$PASS -X POST "$SERVER/app/rest/vcs-root-instances/commitHookNotification?locator=$LOCATOR" -o /dev/null) >/dev/null 2>&1 <&1 &
exit 0
我不太熟悉 Powershell 脚本。我哪里错了?
【问题讨论】:
-
为什么? bash 脚本可以在 Git for Windows bash 环境中完美运行。
-
我们实际上是在为多个存储库编写一个通用的 Powershell 脚本。
-
你不能用 bash 写那个通用的脚本吗?
-
Bitbucket 安装在 Windows 服务器中,这里的脚本适用于基于 Linux 的服务器:confluence.jetbrains.com/display/TCD10/… 我不确定是否可以使用 bash 脚本。
-
是的,你可以。它将由 git bash 解释。在 Windows 上。
标签: git shell powershell