Reputation: 465
I build app distribution with gradle, which a tar file contains everything needed. I created a generic repository in artifactory. I want to upload the tarball to the generic repository.
By looking up this documentation http://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin
I didn't find a way to do so. I am a new gradle and artifactory user, can anyone give me guide.
task uploadDistroTar(type: org._10ne.gradle.rest.RestTask) {
httpMethod = 'PUT'
uri = 'http://x.x.x.x:8081/artifactory/repo/foo.tar'
username = 'admin'
password = 'passwd'
requestContentType = groovyx.net.http.ContentType.BINARY
requestBody = new File("build/distributions/foo.tar").bytes
}
Upvotes: 2
Views: 3078
Reputation: 412
More modern solution is to use Artifactory Java Client:
Artifactory artifactory = ArtifactoryClientBuilder.create()
.setUrl("ArtifactoryUrl")
.setUsername("username")
.setPassword("password")
.build();
java.io.File file = new java.io.File("fileToUpload.txt");
File result = artifactory.repository("RepoName").upload("path/to/newName.txt", file).doUpload();
Upvotes: 1
Reputation: 465
Finally I find the solution by read the plugin's source code, just set:
preemptiveAuth = true
Upvotes: 0
Reputation: 22893
The easiest way will be to use the Gradle REST plugin. Just use the PUT request to upload the file to the repository you want.
Upvotes: 2