Last active
February 23, 2018 14:11
-
-
Save aerobless/3a420460e2387324bb2b55707e0be722 to your computer and use it in GitHub Desktop.
Gradle script to access credentials stored in gnome-keyring
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
String getJFrogPasswordFromSystemKeyring() { | |
def stdout = new ByteArrayOutputStream() | |
def stderr = new ByteArrayOutputStream() | |
exec { | |
commandLine 'secret-tool', 'lookup', 'server', 'git.company.ch' | |
standardOutput = stdout | |
errorOutput = stderr | |
ignoreExitValue = true | |
} | |
return stdout.toString().trim() | |
} | |
ext.jFrogUser = project.properties["jFrogUser"] | |
if (project.hasProperty("jFrogPassword")) { | |
println("Reading jFrog password from gradle.properties") | |
ext.jFrogPassword = project.properties["jFrogPassword"] | |
} else { | |
println("Reading jFrog password from keyring") | |
ext.jFrogPassword = getJFrogPasswordFromSystemKeyring() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment