Jagan
Jagan

Reputation: 37

Uploading files to artifactory from Java

I have a handful of files in Local which I want to deploy to artifactory. I am planning to create a java class which connects to the repository , create folders & then upload the files inside the folder.

Is it possible to do this in Java ? Please suggest me if you are aware of anyother alternatives.

P.S: Communication between local & artificatory is disabled so were not using gradle to upload files to artifactory thus seeking alternatives.

Upvotes: 0

Views: 2257

Answers (2)

Rupesh Reddy Tumu
Rupesh Reddy Tumu

Reputation: 1

You can probably use HttpUrlConnection to make put request to your artifactory instance. Artifactory creates directory structure for you based on the file path you mention. If you want your file to be at https://artifactory.company.com/prod-repo/projA/build10/rhel7/artifact.rpm. You can make a PUT request and Artifactory will create projA/build10/rhel7/ directory structure and deploy file in there, if the path doesn't exist. NOTE that repo (prod-repo) should exist. If you can access your artifactory instance through browser then you will have access to REST API too and thats all you need to perform the action. If not SCP files to jump-server/Vm where can reach artifactory and run your code from there.

Upvotes: 0

Dror Bereznitsky
Dror Bereznitsky

Reputation: 20386

One option is to use the Artifactory REST Client Java API bindings which provides Artifactory connection and management within your Java code.
The other option is using the JFrog CLI - a compact client that provides a simple interface that automates access to JFrog products (including Artifactory).

Upvotes: 3

Related Questions