How to continue build if testng test is failed

Where should I use ignoreFailures setting? i got to know about this in - https://www.mkyong.com/gradle/gradle-how-to-continue-build-if-test-is-failed/

My requirement is I want the gradle build to be successful is any testng test case failures.

Here is my build.gradle.

plugins {
// Apply the java-library plugin to add support for Java Library
id ‘java-library’
}

dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api ‘org.apache.commons:commons-math3:3.6.1’

implementation ‘com.google.guava:guava:23.2’ // This dependency is used internally, and not exposed to consumers on their own compile classpath.
compile group: ‘com.google.guava’, name: ‘guava’, version: ‘25.1-jre’

compile group: ‘org.seleniumhq.selenium’, name: ‘selenium-java’, version: ‘3.14.0’
compile group: ‘io.github.bonigarcia’, name: ‘webdrivermanager’, version: ‘2.2.5’

compile group: ‘log4j’, name: ‘log4j’, version: ‘1.2.17’
compile group: ‘org.slf4j’, name: ‘slf4j-api’, version: ‘1.7.25’
compile group: ‘ch.qos.logback’, name: ‘logback-classic’, version: ‘1.2.3’

compile group: ‘org.apache.commons’, name: ‘commons-collections4’, version: ‘4.1’
compile group: ‘org.apache.commons’, name: ‘commons-lang3’, version: ‘3.3.1’
compile group: ‘org.apache.poi’, name: ‘poi’, version: ‘3.17’
compile group: ‘org.apache.poi’, name: ‘poi-ooxml’, version: ‘3.17’

compile group: ‘org.apache.commons’, name: ‘commons-collections4’, version: ‘4.1’
compile group: ‘org.testng’, name: ‘testng’, version: ‘6.14.3’

compile group: ‘org.yaml’, name: ‘snakeyaml’, version: ‘1.11’
}

// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
mavenCentral()
}

task runTests(type: JavaExec, dependsOn: ‘classes’) {
main = ‘org.testng.TestNG’
classpath = files(“./src/test/resources”,
project.sourceSets.main.compileClasspath,
project.sourceSets.test.compileClasspath,
project.sourceSets.main.runtimeClasspath,
project.sourceSets.test.runtimeClasspath)
args = [“-threadcount”, “1”, “-d”, “./build/”, “./testng.xml”]
}