This topic provides a step-by-step instruction to configure a custom 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 the Select button in the Event Driven Worker tile.
+ Add Additional Worker: To create more Workers after the first one, 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.
(Optional): Some Workers have a code gallery of ready-made code samples, Worker script examples that you can use to inspire and accelerate your work. To use code samples, select Start with Code Gallery from the drop-down menu. Select a code sample from the list and click Apply: the code sample will appear in the Script field in the Worker menu, and you can edit it there.
Note
The code gallery samples are for reference only, aimed to accelerate your development work using real-world examples.
To use an empty, 'Hello-world' example, select Start with Skeleton.
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.
Note
When creating a Worker within a project, you can select only repositories that are directly within the project, and not ones that are shared with the project.
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.zipfiles in the com directory.com/**/test.zip- Matches alltest.zipfiles 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.