Continuous Integration
Blog
Continuous Integration

How to Configure Your Builds with JFrog Artifactory and Harness | Harness Blog

This article will explain how a developer can easily use best-of-the-breed DevOps tools, like Harness and JFrog Artifactory, to test and build with CI and store the build artifacts.

TL;DR

Integrating JFrog Artifactory with Harness CI streamlines the software development lifecycle by enabling seamless storage and reuse of build artifacts, enhancing developer productivity and accelerating software delivery.

JFrog Artifactory is a solution for managing binaries, packages, and repositories, which are known as “software assets” in the world of continuous integration (CI) and delivery (CD). Artifactory helps software developers codify, store, and track files and their metadata without needing to understand their inner workings. It also offers centralized storage of binary assets, so other team members can reuse them. Since all the build artifacts and binaries are stored in a single place, Artifactory provides a single view of the entire development process, enabling developers to share their work seamlessly.

This article will explain how a developer can easily use best-of-the-breed DevOps tools, like Harness and JFrog Artifactory, to test and build with CI and store the build artifacts. This makes it easy for other developers in the team to collaborate and use the stored artifacts, which not only enhances developer productivity but also speeds up the software delivery process. 

Harness has a seamless integration with Artifactory. Users just need to set up a free trial of Harness Continuous Integration, add the test and build steps, and then push the build artifacts to Artifactory. We will see this with a simple example and learn how Artifactory and Harness work together to streamline your software development lifecycle

Code pushed from local machines triggers Harness CI to test, build, and store artifacts in JFrog Artifactory.

Pre-requisites

Setup

First, build a simple Java project with Maven. For the purpose of this tutorial, I have created a simple application, and you can clone it. You can find the example on Github.

Then, log in to your Harness account and create a project.

Harness project creation wizard with the project name artifactory-maven-example filled in

Select the continuous integration module from the list.

Selecting the Continuous Integration module on the Harness project setup screen

Start doing the project set-up by adding a Delegate to the project first. 

Note: You might be a little overwhelmed by thinking about what a delegate is and why it’s required. The Harness Delegate is a service/software you need to install/run on the target cluster (Kubernetes cluster in our case) to connect your artifacts, infrastructure, collaboration, verification, and other providers with the Harness Manager. When you set up Harness for the first time, you install a Harness Delegate. If you want to know more about Delegate, read the Harness Delegate documentation. 

Delegates option selected under Project Setup in the Harness navigation menu

Then add Artifactory as a new connector. 

Harness Project Connectors page showing the New Connector button to begin adding Artifactory

Selecting Artifactory from the Artifact Repositories options in the Harness Connectors menu

Add your Artifactory details like URL, username, and password. Passwords are securely protected at Harness with a strongly encrypted approach. 

Artifactory Repository configuration form in Harness showing URL, username, and password secret fields

Make sure your connection is successful.

Successful connection test for the Artifactory Repository connector in the Harness UI

Next, you need to add your repo as a connector. Various code repository management platforms are supported at Harness. Since our code is on GitHub, we will select Git.

Code Repositories selection screen in Harness showing AWS CodeCommit, Bitbucket, Git, GitHub, and GitLab

After selecting Git, add the repository details.

Configuring GitHub Connector details in Harness with Repository URL type, HTTP connection, and repository URL

Configuring credentials for the GitHub Connector with username and personal access token secrets in Harness

Harness GitHub Connector connection test screen showing a successful verification message

Make sure the connection is successful.

Now, go to creating the pipeline step and add all the relevant details.

Harness empty state screen showing 'There are no pipelines in your project' with a 'Create a Pipeline' button

Name the pipeline and proceed. 

Create new Pipeline dialog in Harness with the name field set to build and push

Then select Build as the stage.

Harness Select Stage Type modal with the Build stage option selected

This step fetches our already connected GitHub repo and the connector. Click on set up stage.

Configuring a Build stage in Harness with a GitHub repository and maven-repo connector

Next, define the infrastructure. We are using a Kubernetes cluster, and we will specify the same.

Selecting Kubernetes or VMs as the build infrastructure in the Harness pipeline editor
Configuring Kubernetes build infrastructure in Harness with maven-kube cluster and default namespace

In the execution stage, Add Step and select Run.

Clicking Add Step in the Execution stage of a Harness pipeline to open the step options menu

Selecting the Run step in the Harness Build step library to execute commands on a container image in a CI stage

Configure Run Step interface in Harness with step parameters for Name, Container Registry, Image, and Command

One more connector to add is our DockerHub Registry. Let’s add that as a connector.

Docker Registry connector setup in Harness, showing DockerHub provider type and username credentials

Make sure the connection is successful.

Harness Connection Test screen showing a successful verification for the Docker Registry connector

Configure the run setup with the details required like name, docker registry connector, image, and command.

Configure Run Step panel in Harness with maven-docker-reg container registry and a maven clean install command

After adding the run step, add another step to push the build artifacts to the Artifactory.

Harness pipeline editor showing the Execution tab with a menu to Add Step after the run test step

Select JFrog Artifactory.

Selecting the Upload Artifacts to JFrog Artifactory step in the Harness Step Library

Mention the details required as we did in the previous step. Just make sure your target and source path is correct. 

Harness step parameters for uploading artifacts to JFrog Artifactory, showing connector, target, and source path

You can see your source path in the target folder of your project after you run mvn install 

Terminal output showing a successful Maven build and the generated JAR file inside the target directory

Now, we are all set. Save the settings and run the pipeline.

Harness pipeline execution flow showing a Build stage with run test and push to artifactory steps

Harness Run Pipeline modal with Git Branch selected and branch name set to main

Harness pipeline execution console logs showing a successful artifact upload to JFrog Artifactory

After the successful execution of all the steps, you should see your build artifacts getting pushed to Artifactory. Let’s verify the same by going to our Artifactory account/dashboard.

Harness pipeline execution showing successful completion of Initialize, Git clone, run test, and push to artifactory
JFrog Artifactory dashboard showing the gs-maven-0.1.0.jar artifact inside the default-maven-local repository

Congratulations, you just pushed our build artifacts to Artifactory with the help of Harness. 

Harness Artifactory Integration

Artifactory is one of the best solutions in the market to keep your binaries intact. In addition, it helps developers speed up the software delivery process by reusing the binaries and promoting them throughout the development pipeline. Harness is a modern software delivery platform that has a strong integration with Artifactory to help organizations simplify DevOps. 

Ready to try this out with Harness CI? Download a free trial.

Learn more: Efficiently Managing Artifact Dependencies

Read more about JFrog Artifactory & Harness

← Previous:
Next: →

Related Resources

Get Started

Get Started with Harness AI

Try the full platform free. No module restrictions, no credit card.

Pavan Belagatti
Developer Advocate
Pavan is an award winning developer evangelist.
pavan-belagatti
Pavan Belagatti