Not sure if it's what you want, but you can get the taskNames that were used when Gradle was called by accessing the project.gradle
object.
ie: given the following build.gradle
task someTask << {
println project.gradle.startParameter.taskNames
}
Then running:
gradle someTask someTask
Gives the output:
:someTask
[someTask, someTask]
BUILD SUCCESSFUL
Total time: 4.34 secs
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…