Update Worker

JFrog REST APIs

Content Type
REST API
ft:sourceType
Paligo

Description: Updates a worker service.

Since: 7.63.2

Security: Platform Admin, Project Admin (for Project Admin, the projectKey query parameter must be set).

Usage:PUT /worker/api/v1/workers

Produces: no-data

Header parameter: Authorization: Bearer

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.

filterCriteria: { 
  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
}

shared

boolean

No

If TRUE, the Worker will be able to be executed by non-admin users. This is only relevant for Workers of type GENERIC_EVENT.

debug

boolean

No

If TRUE, the successful execution for this Worker will also be historized.

projectKey

string

No

If set, this Worker will be available in the scope of the given project (editable by platform admin and project admin). Otherwise this Worker will be global and only editable by platform admin.

If set, only actions that are compatible with projects are returned. If a project admin token is used, this query parameter is required and the user must have the role project admin for the project, otherwise an HTTP error 403 is returned. Once set, the projectKey cannot be changed.

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.