Prevent build crash when non existing task called

It is possible to run Gradle build from command line and avoid to crash when some task not exists?
I’m using TC for building every commit.
But very often happen that I have multiple branches like master a release branch.
In the master, I need to call come new task which is not available in the release branch.
So I would like to add calling this task as optional and allow to build the app also when it is missing.