You could put the credentials in a properties file and read it using something like this:
Properties props = new Properties()
props.load(new FileInputStream("yourPath/credentials.properties"))
project.setProperty('props', props)
Another approach is to define environment variables at the OS level and read them using:
System.getenv()['YOUR_ENV_VARIABLE']