2014-11-05 64 views
1

當gradlew運行flywayRepair或flywayMigrate,返回狀態始終爲0(零),不管成功還是失敗的:gradlew沒有返回飛行用命令的錯誤狀態

./gradlew --quiet -Pflyway.initOnMigrate=true -Pflyway.url=jdbc:mysql://localhost:3306/mars flywayRepair 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':common:flywayRepair'. 
> Error occurred while executing flywayRepair 
    Unable to obtain Jdbc connection from DataSource (jdbc:mysql://localhost:3306/mars) for user 'flyaway' 
    Communications link failure 

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 
    Connection refused 


* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
Exit status from flywayRepair for mars is 0 
+0

無法重現。你是否說「退火狀態從flywayRepair for mars是0」是輸出的一部分,是問題所在?或者你在談論'gradle'命令的實際退出狀態? – 2014-11-06 10:08:04

+0

「我的shell腳本調用gradle任務時發出」退出狀態從fltwat修復mars爲0「。我將跟進並鏈接到腳本示例 – 2014-11-07 06:45:25

+1

聽起來像是您的shell腳本的問題。發生故障的Gradle內部版本的退出狀態爲1. – 2014-11-07 06:59:52

回答

0

這聽起來像一個搖籃問題。我建議你向他們提出問題。

1

您正在檢查shell腳本中/ usr/bin/tee的退出狀態,因爲這是最後執行的命令,在您的情況下,這當然總是爲0。

您應該測試$ PIPESTATUS [0]不是作爲記錄在本頁面:http://tldp.org/LDP/abs/html/internalvariables.html

+0

爲了擴展這一點,您還可以設置-o pipefail,以防止管道中的錯誤被屏蔽。有關更多詳細信息,請參閱http://redsymbol.net/articles/unofficial-bash-strict-mode/。 – tonyg 2015-10-27 13:45:28

+0

那麼,我的鏈接也包含這個選項;-) – Vampire 2016-03-02 15:00:28