This topic provides a step-by-step instruction to configure a scheduled worker. Scheduled workers are a powerful tool that allows you to trigger at predefined times or intervals, which you can define using cron expressions.
Prerequisite
Before starting the configuration, ensure that you have selected the desired project for which you want to apply the worker.
To configure a scheduled 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 Scheduled Worker tile.
+ Add Additional Worker: For the second and more workers, click + New Worker, and then click New Scheduled Worker.
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.
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')
.Scheduled Settings:
In the Cron Expressions, enter the cron expression that you want the worker to follow. For more information, see cron expressions
Under Timezone, select the timezone the worker will use from the drop-down menu. By default, the timezone is UTC.
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.