determine if it is jenkins environment inside gradle
You could check for existence of build-specific environment variables, like $BUILD_ID
or $BUILD_URL
, etc. They really shouldn't exist outside of Jenkins build, but if your environment is polluted, you could have them.