-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecrets.gradle
More file actions
25 lines (23 loc) · 864 Bytes
/
secrets.gradle
File metadata and controls
25 lines (23 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def getLocalSecret(String secretName) {
String keyConfigPath = "${projectDir.path}/secret.properties"
File keyConfigFile = file(keyConfigPath)
if (keyConfigFile.exists()) {
def Properties props = new Properties()
props.load(keyConfigFile.newInputStream())
String prop = props[secretName]
if (prop == null || prop.isEmpty()) {
throw new MissingPropertyException("Missing property $secretName")
} else {
return prop
}
} else {
println("WARNING: No secrets file found using mock value instead. This is proper behavior in case of PR.")
return "1111111111111111111111111111111111111111"
}
}
def loadSecret(String envVarName, String secretName) {
return (System.getenv(envVarName) ?: getLocalSecret(secretName))
}
ext {
loadSecret = this.&loadSecret
}