2015-10-13 44 views
5

我在運行測試的git repo中有一個預推腳本。如果測試通過,推進繼續。如果測試失敗,它會中止推送。git pre-push:在運行測試時由遠程主機關閉連接

該腳本工作了一段時間,直到測試開始超過3分鐘。 stdout會在測試輸出中顯示「連接到由遠程主機關閉的bitbucket」。然後所有的測試都通過了,推送並沒有真正完成。

這裏的預推腳本

#!/bin/sh 
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 

# This script runs tests before any push to the MASTER branch and fails 
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') 
echo "Current branch: "$current_branch 
if [ $current_branch = "master" ] 
then 
    echo "Pushing to MASTER branch requires tests to pass..." 
    ./run.sh test 
    if [ $? = 0 ] 
    then 
     exit 0 
    else 
     echo "***ERROR> Failed to pass tests! Get tests to pass and then try again..." 
     exit 1 
    fi 
else 
    echo "Skipping tests since we're not pushing to MASTER..." 
fi 

回答

1

我最終在成功案例中調用git push --no-verify。所以它有效地推動兩次。

#!/bin/sh 
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 

# This script runs tests before any push to the MASTER branch and fails 
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') 
echo "Current branch: "$current_branch 
if [ $current_branch = "master" ] 
then 
    echo "Pushing to MASTER branch requires tests to pass..." 
    ./run.sh test 
    if [ $? = 0 ] 
    then 
     # workaround to guarantee my push goes through even if the first attempt times out 
     git push --no-verify 
     exit 0 
    else 
     echo "***ERROR> Failed to pass tests! Get tests to pass and then try again..." 
     exit 1 
    fi 
else 
    echo "Skipping tests since we're not pushing to MASTER..." 
fi 
0

你檢查的bitbucket.properties?也許你打了一些超時,如:process.timeout.executionplugin.bitbucket-scm-git.backend.timeout.idle。可能是一個快速檢查,看看是否有超時設置爲180秒。 Here你可以找到更多關於可用屬性的細節。

+0

我可以在哪裏設置這些參數? – saada

+0

@saada請參閱我的更新回答。 – dan

+0

我們沒有託管我們自己的bitbucket服務器,所以我不認爲我有權訪問這些屬性 – saada

相關問題