How to pass TestNG groups through terminal?

Hi Guys,

I was using Selenium+TestNg+ANT where I could trigger a build from terminal or jenkins by calling 'ant -Dgroups=‘sanityTests’.
Recently we migrated from ANT to Gradle and replaced our ‘build,xml’ with ‘’ file. My build.gradle file is as follows;

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'

dependencies {
  compile fileTree(dir: 'lib', includes: ['*.jar'])

task createGradleWrapper(type: Wrapper) {
    gradleVersion = '0.9'

test {
  afterTest { desc, result -> 
        println "Executed test ${} [${desc.className}] with result: ${result.resultType}"

I am not able to pass group name at run time like i used to do with ANT.
./gradlew clean test -Dgroups=‘sanityTests’ will not run tests in that specific group but will run all tests. Can you please provide some insight on this.