2017-08-28 12 views
6

Tôi có kịch bản gradle này:Đóng và giải phóng vật trên maven trung ương sử dụng 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' 
         } 
        } 
       } 
      } 
     } 
    } 
} 

tôi sử dụng nó trên máy chủ Jenkins của tôi và nó hoạt động tuyệt vời. Tôi cũng muốn đóng và giải phóng các hiện vật ... Làm cách nào để thực hiện điều đó?

+0

Bạn có ý nghĩa gì khi * đóng *? –

+0

Quy trình thủ công là tải lên, đóng ... phát hành. – TacB0sS

Trả lời

0

giải pháp là để thêm dòng sau vào file build.gradle root:

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' 

Và chạy sau từ com dòng uỷ quyền:

bash gradlew nexusStagingRelease 

XONG!

0

Bạn có thể sử dụng gradle-release trên tập lệnh của mình. Nó hoạt động tương tự như maven-release-plugin (loại bỏ SNAPSHOT từ phiên bản, bản xây dựng, tạo thẻ, triển khai các đồ tạo tác và cập nhật lên phiên bản phát triển tiếp theo):

apply plugin: 'net.researchgate.release' 

Trong Jenkins, sử dụng release plugin, bạn sẽ cần phải cấu hình unattended release:

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

Plugin này có thể xây dựng các tạo tác từ dự án gradle đa dự án, tải chúng lên trung tâm Maven, đóng và phát hành kho lưu trữ dàn dựng? – TacB0sS

Các vấn đề liên quan