---
title: "Doing DevOps Your Way On SaaS Solutions: Writing Your First JFrog Worker Service to Extend JFrog SaaS"
url: "https://jfrog.com/blog/writing-your-first-jfrog-worker-service/"
canonical: "https://jfrog.com/blog/writing-your-first-jfrog-worker-service/"
lang: "en-US"
type: "article"
description: "The new workers service allows you to create & run custom plugins that extend JFrog Platform functionality via a built-in serverless execution environment. Get started with an example use case."
date: "2023-12-07T16:27:21"
modified: "2024-10-03T19:26:43"
---
# Doing DevOps Your Way On SaaS Solutions: Writing Your First JFrog Worker Service to Extend JFrog SaaS

[Blog Home](https://jfrog.com/blog/)

_**October 2024 Update:** JFrog Workers is now available for all Enterprise+ and Enterprise X customers!_

_For more information, review our_ [_Help Center documentation_](https://docs.jfrog.com/administration/docs/workers)_._

![JFrog Workers Technical How-To](https://speedmedia2.jfrog.com/08612fe1-9391-4cf3-ac1a-6dd49c36b276/jfrog.com/wp-content/uploads/2023/12/JFrog-Workers-Technical-How-To-863x300-1.png)

To recap from [our first blog post](https://jfrog.com/blog/introducing-jfrog-workers-service/), JFrog Workers is a service in the [JFrog Platform](https://jfrog.com/software-supply-chain-platform/) that provides a serverless execution environment, similar to [AWS Lambda services](https://aws.amazon.com/lambda/). The Workers Service is similar to the [user plugins](https://docs.jfrog.com/integrations/docs/user-plugins) available in JFrog self-hosted, and can be used to perform tasks that extend the capabilities of the JFrog Platform according to your requirements.

## How does it work?

The [Workers Service](https://docs.jfrog.com/administration/docs/platform-administration) enables you to create and run plugins that extend JFrog Platform functionality according to our needs, for example, defining a specific artifact upload path to a repository or adding a property to an artifact .

To create a Workers Service, click on the Workers tab under the Administration icon:

![Creating a Workers Service](https://speedmedia2.jfrog.com/08612fe1-9391-4cf3-ac1a-6dd49c36b276/jfrog.com/wp-content/uploads/2023/12/1_Creating-a-Workers-Service.png)

_Creating a Workers Service_

Here’s how we can use automation with the JFrog Workers Service.

## A Simple Example Use Case

A simple use case is adding [properties](https://docs.jfrog.com/artifactory/docs/jfrog-properties) to artifacts. This can later be used with [JFrog REST API’s](https://jfrog.com/help/r/jfrog-rest-apis/jfrog-rest-apis), [JFrog CLI](https://docs.jfrog.com/integrations/docs/jfrog-cli), and [JFrog AQL](https://docs.jfrog.com/pipelines/docs/pipelines-resources). In this example, using a single command we can retrive all artifacts that contain a specific property. Also, we can create other advanced queries, using  JFrog CLI, such as deleting all artifacts uploaded on a specific date that contain a specific property.

Here’s the logic: After an artifact was created → Add a property value.

![Trigger and Action in JFrog Workers Service](https://speedmedia2.jfrog.com/08612fe1-9391-4cf3-ac1a-6dd49c36b276/jfrog.com/wp-content/uploads/2023/12/2_Trigger-and-Action-in-JFrog-Workers-Service.png)

_Trigger and Action in JFrog Workers Service_

**Step1**: We’ll add the name of the project as a property. To do this, click on the workers view and add the “After Create” worker.

![Step 1](https://speedmedia2.jfrog.com/08612fe1-9391-4cf3-ac1a-6dd49c36b276/jfrog.com/wp-content/uploads/2023/12/3_Step-1.gif)

This will create a default worker:

![create a default worker](https://speedmedia2.jfrog.com/08612fe1-9391-4cf3-ac1a-6dd49c36b276/jfrog.com/wp-content/uploads/2023/12/4_create-a-default-worker.png)

**Step 2**: Name our worker, provide a short description, and select the repositories to include.

![Step 2](https://speedmedia2.jfrog.com/08612fe1-9391-4cf3-ac1a-6dd49c36b276/jfrog.com/wp-content/uploads/2023/12/5_Step-2.gif)

**Step 3**: Now let’s edit the code with the property test passed.

```
export default async (context: PlatformContext, data: AfterCreateRequest): Promise => {
   let message = 'OK';
   try {
       await context.clients.platformHttp.put(`/artifactory/api/storage/${data.metadata.repoPath.key}/${data.metadata.repoPath.path}?properties=test=passed`);
  } catch(error) {
      message = `Could not set the property: ${error.message}`;
       console.error(`Request failed with status code ${ error.status || '' } caused by : ${ error.message }`)
   }


   return {
       message,
   }
}
```

**Step 4**: To check our worker and run some tests, add the Key and repository path, and click on run to test it.

![Run to test](https://speedmedia2.jfrog.com/08612fe1-9391-4cf3-ac1a-6dd49c36b276/jfrog.com/wp-content/uploads/2023/12/6_Run-to-test.png)

**Step 5**: Now let’s check our artifacts and see if we added the properties as expected. In this example, the updated repository is “npm-local”. We can see that the property test was added and has the value passed.

![Step 5](https://speedmedia2.jfrog.com/08612fe1-9391-4cf3-ac1a-6dd49c36b276/jfrog.com/wp-content/uploads/2023/12/7_Step-5.gif)

That’s it! We’re done.

## What’s Next

Additional JFrog Workers support will be included in the [JFrog CLI](https://docs.jfrog.com/integrations/docs/download-and-install-the-jfrog-cli), which will enable us to  easily incorporate Workers as part of our pipeline.

For more on workers, visit our [technical documentation](https://docs.jfrog.com/administration/docs/platform-administration), request a demo, or [start a trial](https://jfrog.com/start-free/) to see it in action.

[Blog Doing DevOps Your Way On SaaS Solutions: Custom Plugins Come to JFrog Cloud with Workers Service Read More](https://jfrog.com/blog/introducing-jfrog-workers-service/)

[Blog Doing DevOps Your Way On SaaS Solutions: Connecting JFrog CLI to Your JFrog Workers Read More](https://jfrog.com/blog/doing-devops-your-way-on-saas-solutions-connecting-jfrog-cli-to-your-jfrog-workers/)