Don't break build if specific task fail

Hi all, I’m using a third-party plugin on a multi-project build. The plugin task needs connection to a server, if the server is down the build breaks, the thing is I don’t want to break the build if this task fails.
The difficult part is that i just want this configuration for this task.

Is there a way to accomplish this?

You can use --continue to keep the build going, but it’ll still report failed.

For the given task, you could also do something like:

troubledTask {
   onlyIf { serverIsAvailable() }
}

boolean serverIsAvailable() {
   // code to determine if the server is available
}

That’ll make Gradle skip the particular task if the server is unavailable.

1 Like