How to get the taks which are given as arguments in commandline

I need to know which task are given in the command line , ie. gradle clean build sonarqube

In my my script I want to do something like this:

if (arg.tasks .contains(“sonarqube”)) {
// Do things
}
else {
// Do other things
}

where do I find gradle arguments ?

you can query the tasks provided via commandline by using

gradle.startParameter.taskNames