GEODE-781: Remove the maven-publish-auth plugin Read the settings.xml file directly when build is run by Jenkins.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/d863b6ea Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/d863b6ea Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/d863b6ea Branch: refs/heads/feature/GEODE-217 Commit: d863b6eabce26bec24da60527fa1d4affac9f82d Parents: ed38c5d Author: Anthony Baker <aba...@apache.org> Authored: Sat Jan 16 09:14:14 2016 -0800 Committer: Anthony Baker <aba...@apache.org> Committed: Sat Jan 16 09:38:03 2016 -0800 ---------------------------------------------------------------------- build.gradle | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d863b6ea/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index e651fd9..3163cf7 100755 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,6 @@ buildscript { classpath "gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.2.0" classpath "org.ajoberstar:gradle-git:1.3.2" classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1' - classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1' } } @@ -530,12 +529,24 @@ subprojects { } } - // Jenkins stores auth information in settings.xml. We apply the maven-publish-auth plugin to read that - // from gradle. However, we must match the repository id which the nexus plugin is not exposing. - apply plugin: 'maven-publish-auth' + // The nexus plugin reads authentication from ~/.gradle/gradle.properties but the + // jenkins server stores publishing credentials in ~/.m2/settings.xml (maven). + // We match on the expected snapshot repository id. afterEvaluate { - tasks.getByName('uploadArchives').doFirst { - repositories.each { it.snapshotRepository.id = 'apache.snapshots.https' } + if (!isReleaseVersion && System.env.USER == 'jenkins') { + def settingsXml = new File(System.getProperty('user.home'), '.m2/settings.xml') + def snapshotCreds = new XmlSlurper().parse(settingsXml).servers.server.find { server -> + server.id.text() == 'apache.snapshots.https' + } + + if (snapshotCreds != null) { + tasks.uploadArchives.doFirst { + repositories().withType(MavenDeployer).each { repo -> + repo.snapshotRepository.authentication.userName = snapshotCreds.username.text() + repo.snapshotRepository.authentication.password = snapshotCreds.password.text() + } + } + } } }