Skip to content

Commit 6607204

Browse files
committed
Use VAULT_TOKEN environment variable if it exists (#45525)
1 parent f0061eb commit 6607204

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

.ci/init.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ initscript {
1212

1313
boolean USE_ARTIFACTORY=false
1414

15-
['VAULT_ADDR', 'VAULT_ROLE_ID', 'VAULT_SECRET_ID'].each {
16-
if (System.env."$it" == null) {
17-
throw new GradleException("$it must be set!")
15+
if (System.getenv('VAULT_ADDR') == null) {
16+
throw new GradleException("You must set the VAULT_ADDR environment variable to use this init script.")
17+
}
1818

19-
}
19+
if (System.getenv('VAULT_ROLE_ID') == null && System.getenv('VAULT_SECRET_ID') == null && System.getenv('VAULT_TOKEN') == null) {
20+
throw new GradleException("You must set either the VAULT_ROLE_ID and VAULT_SECRET_ID environment variables, " +
21+
"or the VAULT_TOKEN environment variable to use this init script.")
2022
}
2123

22-
final String vaultToken = new Vault(
24+
final String vaultToken = System.getenv('VAULT_TOKEN') ?: new Vault(
2325
new VaultConfig()
2426
.address(System.env.VAULT_ADDR)
2527
.engineVersion(1)

0 commit comments

Comments
 (0)