How to send Artifactory publish credentials from b

2019-07-20 20:24发布

问题:

Take this snippet from a Gradle build for instance:

repository {
   repoKey = 'libs-snapshot-local'
   username = 'whatever'
   password = 'whatever123'
}

In the past, I've configured Maven (some setting under ~/.m2) to simply pass username/password along. If at all humanly possible I'd like to avoid putting my login credentials for our Artifactory server inside a buildscript. Is there a more secure workaround?

回答1:

you can put a gradle.propertiesfile into your ~/.gradle/ folder.

In this file you can put your credentials:

artifactoryUserName = whatever
artifactoryUserPassword = whatever123

now you can reference these properties in your build script:

repository {
    repoKey = 'libs-snapshot-local'
    username = project.hasProperty('artifactoryUserName') ? artifactoryUserName : ''
    password = project.hasProperty('artifactoryUserPassword') ? artifactoryUserPassword : ''
}