2

当 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
4

3 回答 3

5

两者gradlegradlew都会为失败的构建返回退出状态 1,因此这可能是您的 shell 脚本的问题。或许请参阅Bash-如何检查管道命令的退出状态

于 2014-11-08T06:51:09.357 回答
1

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

您应该测试 $PIPESTATUS[0] 而不是此页面上记录的:http: //tldp.org/LDP/abs/html/internalvariables.html

于 2014-11-08T10:27:36.460 回答
0

这听起来像是一个 Gradle 问题。我建议你向他们提出问题。

于 2014-11-06T08:50:16.453 回答