Update Worker

JFrog REST APIs

Products
JFrog Xray
Content Type
REST API
ft:sourceType
Paligo

Description: Updates a worker service.

Since: 7.63.2

Security: Admin authentication is required.

Usage: PUT /worker/api/v1/workers

Produces: no-data

Sample Usage

curl -X PUT 'https://myserver.com/worker/api/v1/workers'
Ok

Sample Request

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

Parameters

Parameter

Datatype

Mandatory

Description

key

string

Yes

The unique ID of the worker.

description

string

No

Description of the worker.

enabled

boolean

Yes

Whether to enable the worker immediately after creation.

The default values is true.

You can also set the value as false and enable the worker afterwards.

sourceCode

string

Yes

The worker script in TypeScript or JavaScript.

action

enum string

Yes

Choose one of the following worker actions with which the worker is associated.

  • BEFORE_DOWNLOAD

  • AFTER_DOWNLOAD

  • BEFORE_UPLOAD

  • AFTER_CREATE

  • AFTER_BUILD_INFO_SAVE

  • AFTER_MOVE

filterCriteria

object

Mandatory if enabled is set as true.

Defines which repositories are used or excluded.

artifactFilterCriteria: {
        excludePatterns: undefined | string[], // If provided, the worker will be triggered only if the artifact path does NOT matche any of the given patterns
        includePatterns: undefined | string[], // If provided, the worker will be triggered only if the artifact path matches one of the given patterns
        repoKeys: string[], // The list of repositories that are allowed to trigger this worker
}

artifactFilterCriteria.repoKeys

string[]

Mandatory if filterCriteria is mandatory

Defines which repositories are used when an action event occurs to trigger the worker.

You must provide at least one repository.

artifactFilterCriteria: {
        repoKeys: string[], // The list of repositories that are allowed to trigger this worker
}

artifactFilterCriteria.includePatterns

string[]

No

Define patterns to match all repository paths for repositories identified in the repoKeys. Defines those repositories that trigger the worker.

artifactFilterCriteria: {
        includePatterns: undefined | string[], // If provided, the worker will be triggered only if the artifact path matches one of the given patterns
}

artifactFilterCriteria.excludePatterns

string[]

No

Define patterns to for all repository paths for repositories to be excluded in the repoKeys. Defines those repositories that do not trigger the worker.

artifactFilterCriteria: {
        excludePatterns: undefined | string[], // If provided, the worker will be triggered only if the artifact path does NOT matche any of the given patterns
}

secrets

object

No

The secrets to be added to the worker.

You must provide the secret in the following format.

{
    "key": string,
    "value": string
}

Sample Response

{
  "logs": string, // All logs generated by the worker's script appear in one line.
    "beforeDownload": { // The type of action.
        "status": DownloadStatus, // The status returned by the worker script itself.
        "message": string, // The message returned by the worker script.
        "executionStatus": “STATUS_SUCCESS” // Execution status for the worker service.
    }
}

Secret Usage

{
    "key": string, // The name of the secret.
    "value": string // The value of the secret.
    "markedForRemoval": boolean // If "true", the secret will be removed, otherwise an upsert will be performed.
}

Action Usage

{
   enum Action {
    BEFORE_DOWNLOAD,
    AFTER_DOWNLOAD,
    BEFORE_UPLOAD,
    AFTER_CREATE
}

Success Response Codes:

204: Worker service successfully updated.

Error Response Codes:

400 The request payload is malformed.

401 Invalid credentials.

403 Insufficient permissions.

404 Worker does not exist.