This is how:

import com.atlassian.jira.component.ComponentAccessor

String baseUrl = ComponentAccessor.getApplicationProperties().getString("jira.baseurl")


I often use it like:

if (baseUrl.contains("test"))
{
	//We are in test environment
}
else
{
	//We are in prod environment
}