Execute Test

JFrog REST APIs

Products
JFrog Xray
Content Type
REST API
ft:sourceType
Paligo

Description: Test a new worker before creating it, or test an existing worker before updating it.

Since: 7.63.2

Security: Admin authentication is required.

Usage: POST /worker/api/v1/test/[/{workerKey}]

Produces: application/json; charset=utf-8

Header parameter: Authorization: Bearer

Parameters

Name

Datatype

Mandatory

Description

code

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

data

object

Yes

An object that matches the action's event data. The object should match the action that you chose.

workerKey

string

No

If provided, identifies an existing worker to be tested

stagedSecrets

string

No

The secrets to be made available during the test.

If testing an existing worker, its secrets will be made available during the test.

projectKey

string

No

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

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. Once set, the projectKey cannot be changed.

Sample Usage

curl -X POST 'https://myserver.com/worker/api/v1/system/test'
Ok

Sample Request

{
  "code": string,
  "action": string,
  "data": object, // action specific payload
  "stagedSecrets": undefined | Secret[]
}

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.
    }
}

Secrets

Define the secret type:

{
    "key": string, // The name of the secret.
    "value": string // The value of the secret.
}

When testing an existing worker, identified by a workerKey, it is not possible to change the value of an existing secret.

If a staged secret is similar to an existing one, the secret should be marked for removal and then added with a new value, as in the following example.

{
    "stagedSecrets": [
      { “key”: “my-secret-0”, markedForRemoval: true },
      { “key”: “my-secret-0”, “value”: “new-value-of-my-secret-0” }
    ]  
}

Success Response Codes:

200: OK response.

Error Response Codes:

400 The request payload is malformed.

401 Invalid credentials.

403 Insufficient permissions.

422 Error occurs when the worker service cannot encrypt a secret.

500 Error occurred during the request processing.

Sample Errors

Request Error

{  "errors": 
  [
    {      "status": number, // HTTP Error status code
           "message": string // Reason for error
    }
  ]
}

Caution

The status should be either STATUS_SUCCESS or STATUS_FAIL.

Execution Error

{  
  "message": string, // This is the message containing the error.
  "executionStatus": "STATUS_FAIL"  
}