How to check if tests are started in debug-mode from Intellij inside Gradle-Script

I try to figure out how to check if the tests should run with jvm debugging enabled.

I found this post but it is 2 years old:

This does always print false:

    println("DEBUG")
    println(getDebugOptions().getEnabled().get())
    println(getDebug())

What am I doing wrong?

Why am I trying to do this: For some reason the liquibase plugin fails to start

liquibase-plugin: Running the 'liquibaseRun' activity...
ERROR: transport error 202: connect failed: Connection refused

so I figured why not remove the liquibase dependency for debug runs. It would also help to get the liquibase working.