Skip to content

Instantly share code, notes, and snippets.

@aerobless
Last active February 23, 2018 14:11
Show Gist options
  • Save aerobless/3a420460e2387324bb2b55707e0be722 to your computer and use it in GitHub Desktop.
Save aerobless/3a420460e2387324bb2b55707e0be722 to your computer and use it in GitHub Desktop.
Gradle script to access credentials stored in gnome-keyring
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