gradlew 不返回 Flyway 命令的错误状态

Mar*_*ffe 2 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
Run Code Online (Sandbox Code Playgroud)

Pet*_*ser 5

对于失败的构建,和gradle都会gradlew返回退出状态 1,因此这可能是您的 shell 脚本的问题。也许请参阅Bash-如何检查管道命令的退出状态