java - How to publish artifacts to multiple repositories in gradle using JFrog artifactory plugin? - Stack Overflow

admin2025-04-17  2

I am using this plugin:

And below is a sample of my build.gradle

artifactory {
    publish {
        contextUrl = artifactoryUrl
        repository {
            repoKey = "repo-1"
            username = System.getenv("ARTIFACTORY_USER") ?: project.findProperty("artifactory_user")
            password = System.getenv("ARTIFACTORY_PASSWORD") ?: project.findProperty("artifactory_password")
        }
        defaults {
            publications('ALL_PUBLICATIONS')
            publishBuildInfo = false
        }
    }
}

The above task has a name artifactoryPublish and when I run it, its publishing my artifact to repo-1 as defined above. However how should I modify this so it can also publish to repo-2 and repo-3? Is there a way to create a custom task and call the above task in a loop for each of the repos(repo-1, repo-2, repo-3)?

Note: I checked the docs for above plugin and I dont think they have a built-in way to publish to multiple repositories.

转载请注明原文地址:http://anycun.com/QandA/1744882382a88960.html