Maven 如何在两个nexus存储库(jenkins)之间移动工件?

Maven 如何在两个nexus存储库(jenkins)之间移动工件?,maven,jenkins,gradle,nexus,Maven,Jenkins,Gradle,Nexus,我们使用Jenkins+Gradle脚本构建。 要将工件上载到nexus,我们使用: uploadArchives { repositories { mavenDeployer { def auth = { authentication(userName: nexusUsername, password: nexusPassword) } repository(url: rpmReleases

我们使用Jenkins+Gradle脚本构建。 要将工件上载到nexus,我们使用:

uploadArchives {
        repositories {
            mavenDeployer {
                def auth = { authentication(userName: nexusUsername, password: nexusPassword) }
                repository(url: rpmReleasesRepoUrl, auth)
                pom.groupId = project.group
                pom.version = project.version
                pom.artifactId = project.product
            }
        }
    }
我们需要一个作业,它从一个nexus获取工件并将其上传到另一个nexus

你能告诉我做这件事的更好方法是什么,是否有有用的文章/例子(第一次看gradle/maven/nexus)?

1。詹金斯工件升级插件 这是一个非gradle解决方案,但您可以在jenkins工作流中使用它将构建二进制文件从一个nexus repo升级到另一个

2.使用命令行参数提供用于发布的repo URL 然后运行
gradleuploadarchives-PrepoURL=http://nexusurl
根据需要使用不同的nexus url

3.使用不同的任务发布到每个repo
ext.repoURL=''

task publishtorep1()为什么不发布两次?每一个nexus?版本必须测试一次,然后才能发送给客户。测试是手动步骤吗?nexus的免费版本中有一个Jenkinsn插件,允许您在nexus实例之间升级二进制文件:yeap,负责测试的测试团队。谢谢,我会看看的!这不符合用户的要求。它显示了如何上传到两个回购协议,但遗漏了如何从一个回购协议中检索并上传到第二个回购协议。
uploadArchives {
    ...
            repository(url: project.getProperty('repoURL'), auth)
    ...
}
ext.repoURL=''

task publishToRepo1()<<{
    repoURL = 'http://nexus1.url'
    configureRepo(repoURL)
}
publishToRepo1.finalizedBy('uploadArchives')

task publishToRepo2()<<{
    repoURL = 'http://nexus2.url'
    configureRepo(repoURL)
}
publishToRepo2.finalizedBy('uploadArchives')

def configureRepo(url){
    uploadArchives.repositories {
        mavenDeployer {
            def auth = { authentication(userName: nexusUsername, password: nexusPassword) }
            repository(url: url, auth)
            pom.groupId = project.group
            pom.version = project.version
            pom.artifactId = project.name
        }
    }
}

uploadArchives {
    doFirst{
        if (!repoURL){
            println "Please use publishToRepo1 or publishToRepo1 to publish"
            throw new GradleException('use of uploadArchives is restricted!')
        }
    }
}