How to capture the Gradle exit code in a shell script?
问题 I would like to capture the return code of a Gradle task. Here is a small bash script draft which executes a tasks: #!/bin/bash gradlew_return_code=`./gradlew assembleDebug` echo ">>> $gradlew_return_code" if [ "$gradlew_return_code" -eq "0" ]; then echo "Gradle task succeeded." else echo "Gradle task failed." fi The script does not store the return value but instead the whole console output of the Gradle task. Please note that the example script is a simplification of a more complex script