Seth Barrett

Daily Blog Post: May 27th, 2023

java

May 27th, 2023

Managing and Distributing Binary Artifacts with Artifactory: A DevOps Guide

Welcome back to our DevOps series! In the previous post, we explored how to set up a Jenkins pipeline to build and test a Docker container and publish it to Artifactory. In this post, we'll dive deeper into Artifactory and explore how to manage and distribute binary artifacts.

Step 1: Uploading Artifacts to Artifactory

To upload artifacts to Artifactory, we can use the curl command or a build tool like Maven or Gradle.

For example, to upload a JAR file using curl, we can use the following command:

curl -u USERNAME:PASSWORD -X PUT "http://ARTIFACTORY_URL/libs-release-local/com/example/my-app/1.0/my-app-1.0.jar" -T /path/to/my-app-1.0.jar

This command uploads the JAR file to the com/example/my-app/1.0/ directory in the libs-release-local repository in Artifactory.

Step 2: Managing Artifacts in Artifactory

Once artifacts are uploaded to Artifactory, we can manage them using the Artifactory web UI or the Artifactory REST API.

For example, we can search for artifacts using the following REST API endpoint:

http://ARTIFACTORY_URL/api/search/artifact?name=my-app&repos=libs-release-local

This endpoint searches for artifacts with the name "my-app" in the libs-release-local repository.

We can also view the properties of an artifact, such as its checksum and creation date, using the following REST API endpoint:

http://ARTIFACTORY_URL/api/storage/libs-release-local/com/example/my-app/1.0/my-app-1.0.jar

Step 3: Distributing Artifacts from Artifactory

Once artifacts are uploaded and managed in Artifactory, we can distribute them to other systems using the Artifactory web UI or the Artifactory REST API.

For example, we can use the following REST API endpoint to download an artifact from Artifactory:

http://ARTIFACTORY_URL/libs-release-local/com/example/my-app/1.0/my-app-1.0.jar

This endpoint downloads the JAR file from the com/example/my-app/1.0/ directory in the libs-release-local repository in Artifactory.

We can also configure build tools like Maven or Gradle to download artifacts from Artifactory as part of the build process.

Step 4: Setting up a Virtual Repository

To simplify the process of managing and distributing artifacts, we can create a virtual repository in Artifactory that aggregates multiple repositories, such as local, remote, and distribution repositories.

To create a virtual repository, go to Artifactory > Admin > Repositories > Virtual Repositories and click "New Virtual Repository". Give the repository a name and select the repositories that should be aggregated.

With a virtual repository in place, we can distribute artifacts to other systems using a single URL, which simplifies the configuration of build tools and makes it easier to manage and distribute artifacts.

And that's it! With Artifactory, we can easily manage and distribute binary artifacts as part of our software development process. In the next post in this series, we'll explore how to use Docker and Artifactory together to create a container registry.