The following code is from one of my test case startup scripts:
def activeEnviroment = testRunner.getTestCase().getTestSuite().getProject().getActiveEnvironmentName()
log.info('Active enviroment = ' + activeEnviroment)
You need to get hold of the project object as this is where most of the methods relating to environments are, depending where your Groovy script is it might be subtly different from the above.
The getActiveEnvironmentName is implemented by a "Pro" class so the method doesn't show up in Ready API code completion (This limitation was raised with SmartBear issue API-957).