Created
October 15, 2016 13:07
-
-
Save baz8080/87d8840fede76b1aeef6f4ab9ca98722 to your computer and use it in GitHub Desktop.
Gets a environment variable, or falls back to a property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Looks for the specified configuration key in this order: | |
* | |
* <ol> | |
* <li>system environment</li> | |
* <li>project properties</li> | |
* </ol> | |
* | |
* If it isn't found, then the empty string is returned. This stops the gradlew from failing until | |
* it actually needs those values. | |
* | |
* @param keyName The key to look for | |
* @return The value or the empty string if not found | |
*/ | |
def getConfigurationParameter(String keyName) { | |
return System.getenv(keyName) ?: | |
rootProject.hasProperty(keyName) ? rootProject.properties[keyName] : '' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment