Bitbucket钩子:无法获取stash env变量

时间:2016-12-07 17:51:14

标签: git bitbucket bitbucket-api bitbucket-server

我在git repo的pre-receive.d文件夹中有一个pre_receive钩子,用shell脚本编写,钩子正在正确执行但是stash env变量不可用,即它们返回空值,是否有任何服务器端env变量需要配置吗?

#!/bin/sh
echo "pre-receive message 30"
echo "STASH_USER_EMAIL:-"$STASH_USER_EMAIL
echo "STASH_PROJECT_NAME:-"$STASH_PROJECT_NAME

返回

远程:预接收消息30
remote:STASH_USER_EMAIL: -
remote:STASH_PROJECT_NAME: -

任何帮助都将受到高度赞赏。

1 个答案:

答案 0 :(得分:1)

complete pre-receive test script中设置更多your pre-receive.d folder

#!/bin/bash
(
        echo "Script name: $0"
        echo "Positional arguments: ${@}"
        echo "STASH_USER_NAME: $STASH_USER_NAME"
        echo "STASH_USER_EMAIL: $STASH_USER_EMAIL"
        echo "STASH_REPO_NAME: $STASH_REPO_NAME"
        echo "STASH_IS_ADMIN: $STASH_IS_ADMIN"
        while read from_ref to_ref ref_name; do
                echo "Ref update:"
                echo " Old value: $from_ref"
                echo " New value: $to_ref"
                echo " Ref name:  $ref_name"
                echo " Diff:"
                git show $to_ref | sed 's/^/  /'
        done
) | tee -a /tmp/external-hooks-test.log

看看是否会影响这些环境变量值。

相关问题