What are Gradle's possible exit statuses?

I am running Gradle as part of a Jenkins pipeline. As the Gradle plugin for Jenkins doesn’t yet support pipelines, I’m running ./gradlew <task> in a shell step. If tests fail, I’d like my build status to be “unstable”, whereas if Gradle encounters some other error, I’d like the build status to be “failed”. I therefore need my pipeline to understand which, if any, tasks failed.

Does Gradle just exit 0 if everything succeeded and 1 otherwise? Or does it exit with different statuses depending on the type of failure? For example, does a syntax error in the build script produce a different exit status to a test failure? I could find out some of this by experimentation, but it would be great if it was documented.

3 Likes

I think so. But I’s love to have it the way you described too.
Created a ticket: Different exit code for failing test and other gradle problems · Issue #12374 · gradle/gradle · GitHub
Please vote.