This topic provides a step-by-step instruction to configure an event-driven worker for Artifactory. Event-driven workers are a powerful tool that allows you to automate actions in response to specific events occurring within your Artifactory environment.
Prerequisite
Before starting the configuration, ensure that you have selected the desired project for which you want to apply the worker.
To configure an event driven worker for Artifactory, follow these steps:
Step 1: Navigate to the Workers Configuration
Navigate to the Administration module and click Workers.
+ Add your first Worker: If you are creating a worker for the first time, click Select button in the Event Driven Worker tile.
+ Add Additional Worker: For the second and more workers, click + New Worker, and then click New Event Driven Worker.
From the Create New Worker drop-down, click Artifactory to see available Artifactory Workers.
Locate the desired Artifactory Worker, and then click Add.
Step 2: Configure Worker Fields
In the Add New Worker window, enter the details in the relevant fields:
Name: Enter a descriptive name for the worker.
Script: Enter or modify the script in the TypeScript Editor. Use the auto-complete function for improved efficiency while coding.
Worker Settings
Click the Settings icon from the top-right corner of the window, and then enter the details in the relevant fields:
Enable Worker: Enable the worker in the Worker Settings modal by clicking the toggle button.
Note
The worker can also be enabled later from the Add New Worker window or Configured window. Repositories must be selected to enable the worker. Once enabled, the worker triggers when a predefined event occurs.
Description: Enter a brief description of the worker.
Repositories: Click the + icon in the Repositories field.
You can either:
Select Repositories: Move selected repositories from the Available Repositories list.
Set Patterns: Use wildcards (for example, *, **, ?) to define patterns for repository selection.
Example Patterns:
com/t?st.zip
- Matchescom/test.zip
,com/tast.zip
, etc.com/*.zip
- Matches all.zip
files in the com directory.com/**/test.zip
- Matches alltest.zip
files in subdirectories ofcom
.
You can add multiple patterns to the filter. After you enter a pattern, click + to add that pattern to the filter.
Note
For more information, see AntPathMatcher Documentation.
Select Secrets: Secrets are stored securely and not in plain text. The secret's clear-text value is never returned in an API or UI and will be masked from all the logs.
To add a secret:
Enter the Name and Value of the secret.
Click + Add secret to add more secrets.
Click Delete icon to remove any secret.
Note
Use secrets in your code with the syntax:
context.secrets.get('secretName')
.Enable Debugging: Click the checkbox for Show Status of Successful Executions in the Troubleshooting tab to view successful execution results. By default, only unsuccessful executions are shown.
Click OK when done.
Step 3: Testing Pane
Edit the JSON payload used to simulate the worker's events.
Click Run to test the worker.
Review results in:
Execution Results tab: for responses
Execution Logs tab: for logs
Metrics tab: for run time, memory, and CPU utilization details.
Step 4: Save Your Configuration
Click Save to finalize the worker configuration.
To cancel the configuration, click Close, and then click Discard to discard changes.