gradlew没有返回flyway命令的错误状态

时间:2014-11-05 20:22:53

标签: gradle flyway gradlew

当gradlew运行flywayRepair或flywayMigrate时,无论成功或失败,返回状态始终为0(零):

./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

3 个答案:

答案 0 :(得分:3)

对于失败的构建,gradlegradlew都将返回退出状态1,因此这可能是您的shell脚本的问题。也许看Bash - how to check the exit status of pipe command

答案 1 :(得分:1)

您正在检查shell脚本中/ usr / bin / tee的退出状态,因为这是最后执行的命令,在您的情况下,这当然总是0。

您应该测试$ PIPESTATUS [0],如本页所述:http://tldp.org/LDP/abs/html/internalvariables.html

答案 2 :(得分:0)

这听起来像Gradle问题。我建议你提出问题。