Skip to main content

How to set up JFrog Artifactory as a Repository in Pega.

Before delving into the topic, let's gain some understanding of what a repository is...........

What is a repository?

A repository is a centralized storage location where data, files, documents, or other digital assets are stored and managed. It serves as a single source of truth for organizing, versioning, and accessing these assets. 

In the context of software development, a repository typically refers to a version control system, where developers store and manage source code, configuration files, documentation, and other project-related files. Version control systems like Git, Subversion (SVN), and Mercurial are commonly used repositories in software development.

In addition to version control systems, repositories can also refer to databases, file systems, content management systems (CMS), or any other structured storage system used to manage digital assets.

Overall, a repository provides a structured and organized way to store and manage digital assets, facilitating collaboration, versioning, access control, and tracking of changes over time.

In Pega, repositories are utilized for storing artifacts and attachments. Today, we'll explore how to integrate and leverage third-party repositories to store attachments within the Pega platform.

The default storage location for attachment files in Pega is the database. While using the database is suitable for most cases, if dealing with a large volume of files, it's advisable to consider alternative repositories such as Amazon S3, JFrog Artifactory, Microsoft Azure, or a file system. This is recommended for the following reasons:

1.Storing data directly in the database can be resource-intensive. The system converts FileStream into Base64 Strings and stores them in a Blob field, increasing the size by approximately 33%. Additionally, retrieving data through SQL and decoding it back into a file can be time-consuming. Utilizing a repository significantly reduces the workload on the database.

2.When using the database, if an end user attempts to attach a file to a case, the system temporarily loads the entire file into memory twice. For example, if the attachment file is 1GB, approximately 2.6667GB of the app node's heap size is consumed. In contrast, utilizing a repository allows for the direct upload of the file to the repository without loading it onto the Pega app node.


Additionally, it's important to note that a repository isn't restricted solely to file attachment usage but can accommodate any file storage requirements. For instance, if you intend to install Deployment Manager on-premises, you'll require a separate repository for storing product files. A database cannot fulfill this use case.

Below are some of the repositories commonly used in Pega, along with the details required for their configuration:


In this article, we will explore JFrog Artifactory.

1-1. Look for a free trial of JFrog Artifactory Cloud. I registered via Jfrog Free


1-2. I've created a username and password.


1-3. Now with the username and password, I successfully logged in to JFrog Cloud.


1-4. Next, navigate to "Repositories" under "Artifactory" in the navigation menu. Click on "Create Repository" and choose "Local," as illustrated in the figure below.

1-5. Select "Generic"


1-6. Enter Repository Key and click on create repository.


1-7.Upon clicking "Create Repository," the following screen appears.



1-8. By navigating to Application > Artifacts and clicking on your Repository Key, you'll find detailed information. Take note of the URL. In this example, it is: https://ethpega.jfrog.io/artifactory/ETHPega/


Now it's time to configure settings in Pega:

1. Create a Repository rule

1-1. From Dev Studio, create a Repository in Records Explorer.


1-2. Name your repository.


1-3. Choose JFrog Artifactory as the repository type.


1-4. Provide the URL for the Host ID and Repository Key. In my case, I entered "https://ethpega.jfrog.io/artifactory/ETHPega/" for the Host ID and "ETHPega" for the Repository Key. Next, specify a name for the Authentication Profile and click on the gear icon to create one. 



1-5. Enter a custom name for the Authentication profile and click on the gear icon to create it.


1-6. Ensure that you select "Basic" for the Type. Unlike Amazon S3 or Microsoft Azure, there is no specific type of authentication profile for JFrog Artifactory.



1-7. Input your username and password. These are the credentials used to log in to JFrog Cloud.


1-8. Click the "Test Connectivity" button and ensure that the Connection status displays "SUCCESS."



2. Configure Application rule.

2-1. Now, let's configure the repository for your attachment files. In the application rule, specify "Artifactory" in the Content storage section as shown below.


2-2. If there are no directories in JFrog Artifactory, you will only find the "/" (root) directory, as shown below. Select "/" to proceed.


2-3. I attempted to create a subdirectory in JFrog Artifactory but found it is not possible through the user interface. However, I discovered that there is a REST API available for creating a folder.

Below is a sample of how to create a folder using Postman:

1. Select "PUT" and enter the URL, followed by the name of the folder you want to create. In this example, I entered "attachments". Note that you should include a slash "/" after the folder name. For example: `/attachments/`.

2. For the authorization type, select "Basic Auth" and provide your credentials.

3. Click the "Send" button and you should receive a 201 HTTP status code.

Check JFrog Artifactory to see if the new folder is created successfully.



2-4. In Dev Studio, you can now select the subdirectory "attachments."


2-5. The application is configured as follows.


3. Let's test now

3-1. Now, let's attach a file to a case from the workflow.

3-2. Choose a file from your local system.


3-3. Now submit, and the file will be attached to a case.


3-4. You can verify that the file is uploaded to JFrog Artifactory as follows. The file is stored with its original filename followed by an underscore and the case ID.




Happy Learning :)

Comments

Popular posts from this blog

Understanding the Lock Mechanism in Pega

Now, let's delve into the Pega lock mechanism. To begin, Pega employs both database-level locks, which are of shorter durations (usually in milliseconds), and Pega-level locks, which extend over more extended periods (determined by user operations, often a few minutes). While you have the option to disable Pega-level locks using the Optimistic locking strategy (discussed later), database-level locks cannot be turned off; they are an integral part of the infrastructure layer. Moving forward, I'll elaborate on Pega-level locks. 1. Fundamentals of Pega-Level Locks When an individual initiates an assignment, the system transitions the state to "Perform" mode and acquires a lock. This lock data is then added to the "PR_SYS_LOCKS" table in the database, where it is systematically managed. Throughout this phase, no other user can access the same assignment. Upon the user's submission or cancellation of the assignment, the state shifts to "Review" mode...

Building a CSV File Download Function from a Page List

Consider a scenario where we want to download recently added table data from the screen into a CSV format for analysis. Today, we will explore how to accomplish this in Pega. An existing out-of-the-box activity named "pxConvertResultsToCSV" is available in the @baseclass, and you can utilize it without the need to create it from the ground up. The following example illustrates a sample screen: when the button is clicked, the Page List data on the screen is downloaded as a CSV file to the end user's local machine. 1.To begin, establish a Page List property. In this instance, I defined a Data class, "MyCo-Data-Item," and subsequently generated a Page List named "ItemList" in the Work class, referencing the Item class. 2.Position a table that references the Page List, and configure it to be inline-editable, allowing the addition of records directly from the screen. Additionally, position a button in close proximity to the table. 3.Configure the button by ...