A dumb solution would be to just make your build aware that it;'s running on jenkins and utilze solution nr 2 . Just add some project property from command line: ./gradlew -Pjenkins=true … and use that:
test.enable = project.hasPropety(‘jenkins’) && jenkins
The test will be disabled if nothing is supplied - on developer machine