2017-08-28 85 views
6

我有这个脚本的gradle:Maven的中央关闭和释放的神器使用gradle这个

def configureUploadArtifacts(groupId, repoUrl, _packaging) { 
    def gpgKeyId = System.getenv('GPG_KEY_ID') 
    def gpgPassword = System.getenv('GPG_KEY_PASSWORD') 
    def gpgFile = System.getenv('PATH_TO_GPG_FILE') 

    project.group = groupId; 
    project.archivesBaseName = name 
    project.version = getVersionNameFromFile() 

    ext."signing.keyId" = gpgKeyId 
    ext."signing.password" = gpgPassword 
    ext."signing.secretKeyRingFile" = gpgFile 

    uploadArchives { 
     apply plugin: 'maven' 
     apply plugin: 'signing' 

     signing { 
      sign configurations.archives 
     } 

     def userName = System.getenv('OSSRH_USER_NAME'); 
     def password = System.getenv('OSSRH_PASSWORD'); 

     repositories { 
      mavenDeployer { 
       beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 

       repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { 
        authentication(userName: userName, password: password) 
       } 

       snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { 
        authentication(userName: userName, password: password) 
       } 

       pom.project { 
        name "${project.name}" 
        packaging "${_packaging}" 

        // optionally artifactId can be defined here 
        description 'A collection of core tools I use' 
        url "http://github.com/${repoUrl}" 

        scm { 
         connection "scm:git:git://github.com/${repoUrl}.git" 
         developerConnection "scm:git:ssh://github.com/${repoUrl}.git" 
         url "http://github.com/${repoUrl}/tree/master" 
        } 

        licenses { 
         license { 
          name 'The Apache License, Version 2.0' 
          url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 
         } 
        } 

        developers { 
         developer { 
          id 'TacB0sS' 
          name 'My Name' 
          email 'My Email' 
         } 
        } 
       } 
      } 
     } 
    } 
} 

我用它我詹金斯服务器上,它奇妙的作品。 我也想关闭并释放工件... 我该怎么做?

+0

是什么意思*关闭*? –

+0

手动过程是上传,关闭...发布。 – TacB0sS

回答

0

的解决办法是添加以下到根的build.gradle文件:

ext."oss-releases.username" = System.getenv('OSSRH_USER_NAME') 
ext."oss-releases.password" = System.getenv('OSSRH_PASSWORD') 
ext."oss-releases.url" = "https://oss.sonatype.org/index.html#stagingRepositories" 

apply plugin: 'nexus-workflow' 

并运行从COM以下mand line:

bash gradlew nexusStagingRelease 

DONE!

0

您可以在脚本上使用gradle-release。它可以作为Maven的释放小插件类似(从版本中删除快照,构建,创建标签,部署文物和更新到下一个开发版本):使用release plugin

apply plugin: 'net.researchgate.release' 

在詹金斯,你将需要配置unattended release

gradle release -Prelease.useAutomaticVersion=true \ 
       -Prelease.releaseVersion=$VERSION \ 
       -Prelease.newVersion=$NEXT_VERSION 
+0

这个插件可以从多项目gradle项目构建工件,将它们上传到Maven central,关闭并释放暂存仓库? – TacB0sS