Types of Workers and Code Samples

JFrog Platform Administration Documentation

Content Type
Administration / Platform
ft:sourceType
Paligo

Note

You use the same Create Worker API to create all workers. You differentiate between the type of worker in the payload. See more.

Artifactory Event Driven

Code samples and procedures for creating Artifactory event-driven workers are provided below.

Event

Sample Code

Create using Platform UI

Using API

Before downloading an artifact in Artifactory

Note: Only customers with JFrog Advanced Security (JAS) can block an artifact download. Otherwise Artifactory proceeds with the download but the system will log an error.

Before Download Worker Code Sample

Create a Before Download Worker

Create WorkerCreate Worker

POST ${baseUrl}/worker/api/v1/workers

After downloading an artifact in Artifactory

After Download Worker Code Sample

Create a Before Download Worker

Create a Before Download Worker

POST ${baseUrl}/worker/api/v1/workers

Before an upload request is run in Artifactory

Note: Only customers with JFrog Advanced Security (JAS) can block an artifact upload. Otherwise Artifactory proceeds with the upload but the system logs an error.

Before Upload Worker Code Sample

Create a Before Download Worker

Create Worker *Create Worker

POST ${baseUrl}/worker/api/v1/workers

After creating an artifact in Artifactory

After Create Worker Code Sample

Create a Before Download Worker

Create WorkerCreate Worker

POST ${baseUrl}/worker/api/v1/workers

Before deleting an Artifactory property

Before Delete Property Worker Code Sample

Create a Before Delete Property Worker

Create WorkerCreate Worker

POST ${baseUrl}/worker/api/v1/workers

Before deleting an artifact

Before Delete Worker Code Sample

Create a Before Delete Worker

Create WorkerCreate Worker

POST ${baseUrl}/worker/api/v1/workers

After moving an artifact from one repository to another in Artifactory

After Move Worker Code Sample

Create a Before Download Worker

Create WorkerCreate Worker

POST ${baseUrl}/worker/api/v1/workers

After build info has been saved in Artifactory storage

After Build Info Save Worker Code Sample

Create a Before Download Worker

Create WorkerCreate Worker

POST ${baseUrl}/worker/api/v1/workers

Access Event Driven

Code samples and procedures for creating Access event-driven workers are provided below.

Event

Sample Code

Create using Platform UI

Using API

Before creating a token

Before Create Token Worker Code Sample

Create a Before Create Token Worker

Create WorkerCreate Worker

POST ${baseUrl}/worker/api/v1/workers

Before revoking a token

Before Revoke Token Worker Code Sample

Create a Before Revoke Token Worker

Create WorkerCreate Worker

POST ${baseUrl}/worker/api/v1/workers

HTTP Triggered

Code samples and procedures for creating HTTP triggered workers are provided below.

Event

Sample Code

Create using Platform UI

Using API

Create a custom code worker independent of any events in the JFrog Platform

Execute Worker for Generic Event Code Sample

Create a Generic Worker

Create WorkerCreate Worker

POST ${baseUrl}/worker/api/v1/workers

Runs custom code independent of any events in the JFrog Platform, can create a generic event

Execute Worker for Generic Event-Execute Worker for Generic Event

POST ${baseUrl}/worker/api/v1/execute/{workerKey}
Using the Create Worker API

You use the same API to create all the workers. You differentiate between the type of worker created using the action parameter in the request payload. Using the action parameter in the API request payload, you specify the event with which the worker is associated.List of Worker Events

Sample Request Payload

{
    "key": string,
    "description": string,
    "enabled": boolean,
    "sourceCode": string,
    "action": string,
    "filterCriteria": {
        "artifactFilterCriteria": {
            "includePatterns": undefined | string[],
            "excludePatterns": undefined | string[],
            "repoKeys": string[]
        }
    },
    "secrets": undefined | Secret[],
    "shared": boolean,
    "debug": boolean,
    "projectKey": undefined | string
}