3

I've been looking around for a way to encrypt password when it comes to upload an artifact to my "Archiva" repository and it seems all of the solutions do support Artifactory and Nexus. Is there a way to do it with Archiva in Gradle. Snippet below:

publishing {
    publications {
        maven(MavenPublication) {
            groupId 'com.x'
            version sprint + buildNumber
        }
    } 

    repositories {  
        maven {
            credentials {
                username "admin"
                password "admin"
            }
            url "snapshots"
        }
    }
}

1 Answers1

4

Gradle doesn't currently solve this problem out-of-the-box; you'll have to devise your own solution. A common solution is to put (unencrypted) credentials into the CI server's ~/.gradle/gradle.properties (access to which will be naturally restricted), then reference them from the build script. Note that many encryption solutions in this space are based on "security by obscurity", and therefore aren't safe.

Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • I'm using the 'maven-settings' plugin to load Maven-encrypted credentials into Gradle (while I transition fully from Maven to Gradle). This solution comes from here https://stackoverflow.com/a/38103564/410939 and works for me with Artifactory (I can't foresee issues with Archiva). – Alex Aug 28 '19 at 13:16