CLI for JFrog Platform Services

Initialize, deploy, test, and manage JFrog Workers from the command line.

This page describes how to use JFrog CLI with JFrog Platform Services. For more information on the CLI in general, see JFrog CLI.

Managing JFrog Workers

Workers is a JFrog Platform service that you can use to extend and control your execution flows. It provides a serverless execution environment where you can create workers to enhance the platform's functionality.

Workers run in the following ways:

  • Automatically, triggered by events within the JFrog Platform for specific use cases.
  • On-demand, using HTTP-triggered workers.

For more information, see JFrog Workers. To configure workers using the JFrog Platform UI instead, see Configure Workers for Custom Flows.

This page covers the following JFrog CLI worker commands:


Initialize JFrog Worker

Use this command to initialize a new JFrog worker.

ParameterCommand / Description
Command nameworker init
Abbreviationworker i
Command options:
--server-id[Optional] Server ID configured using the config command.
--timeout-ms[Default: 5000] The request timeout in milliseconds.
--force[Default: false] Whether to overwrite existing files.
--no-test[Default: false] Whether to skip test generation.
--application[Optional] The application that provides the event. If omitted the service will try to guess it and raise an error if no application is found.
--project-key[Optional] The key of the project that the worker should belong to.
Command arguments:
actionThe name of the action to init (for example, BEFORE_DOWNLOAD). To have the list of all available actions use jf worker list-event.
worker-nameThe name of the worker.

This command generates the following files:

  • manifest.json: Contains the Worker specification, including its name, code location, secrets, and other data useful to the Worker.
  • package.json: Describes the development dependencies of the Worker. This file is not used when executing your Worker in the runtime.
  • worker.ts: The Worker source code, populated with sample code for the event.
  • worker.spec.ts: The source code for the Worker's unit tests.
  • tsconfig.json: The TypeScript configuration file.
  • types.ts: A file containing the event's specific types that can be used in the Worker code.

Example: Initialize a BEFORE_DOWNLOAD Worker

This example initializes a new BEFORE_DOWNLOAD Worker named my-worker.

jf worker init BEFORE_DOWNLOAD my-worker

Test-Run JFrog Worker

Use this command to test-run a Worker. You must initialize the Worker before running this command. The command executes the Worker with its local content, so you can use it to test the Worker's execution before pushing local changes to the server.

ParameterCommand / Description
Command nameworker test-run
Abbreviationworker dry-run, worker dr, worker tr
Command options:
--server-id[Optional] Server ID configured using the config command.
--format[Default: json] Output format. Supported values: json, table. Available from JFrog CLI 2.105.0.
--timeout-ms[Default: 5000] The request timeout in milliseconds.
--no-secrets[Default: false] Do not use registered secrets.
Command arguments:
json-payloadThe json payload expected by the worker. Use - to read the payload from standard input. Use @<file-path> to read from a file located at <file-path>.

Test-Run JFrog Worker Example

This example test-runs a Worker that has been initialized in the current directory, using a payload from a file named payload.json in the same directory.

jf worker dry-run @payload.json

--format json output (default)

{
  "key": "my-worker",
  "workerKey": "my-worker",
  "triggeredByEvent": "BEFORE_DOWNLOAD",
  "statusCode": 200,
  "status": "STATUS_SUCCESS",
  "warnings": [],
  "errors": [],
  "debug": []
}

--format table output

jf worker dry-run @payload.json --format table
key          workerKey   triggeredByEvent   statusCode  status          warnings  errors  debug
my-worker    my-worker   BEFORE_DOWNLOAD    200         STATUS_SUCCESS

Deploy JFrog Worker

Use this command to update the worker definition (code, description, filter, secret, and so on) on your Artifactory instance.

ParameterCommand / Description
Command nameworker deploy
Abbreviationworker d
Command options:
--server-id[Optional] Server ID configured using the config command.
--format[Optional] Use --format json to return the response as JSON. Available from JFrog CLI 2.105.0.
--timeout-ms[Default: 5000] The request timeout in milliseconds.
--no-secrets[Default: false] Do not use registered secrets.
--changes-version[Optional] Version identifier for the worker.
--changes-description[Optional] Description of your changes.
--changes-commitsha[Optional] Commit identifier or your change in your VCS.
--base64[Default: false] Encode the worker source code in base64 before sending.

Deploy JFrog Worker Example

Deploy a worker to the server with id my-server.

jf worker deploy --server-id my-server

--format json output

jf worker deploy --server-id my-server --format json
{
  "status_code": 200,
  "content": "{\"key\":\"my-worker\",\"version\":\"1\"}"
}

Add Secrets to JFrog Worker

Use this command to edit a worker manifest to add or edit a secret used for deployment or execution.

Secrets are stored encrypted with a master password that will be requested by the command.

Once secrets are added to the manifest, the master password will be required by the deploy and test-run commands.

ParametersCommands / Description
Command nameworker add-secret
Abbreviationworker as
Command options:
--edit[Default: false] Whether to update an existing secret.
Command arguments:
secret-nameThe secret name

Add Secrets to JFrog Worker Example

Add the secret name my-secret to a worker initialized in the current directory.

jf worker add-secret my-secret

Undeploy JFrog Worker

Use this command to remove a registered worker from your Artifactory instance.

ParameterCommand / Description
Command nameworker undeploy
Abbreviationworker rm
Command options:
--server-id[Optional] Server ID configured using the config command.
--format[Optional] Use --format json to return the response as JSON. Available from JFrog CLI 2.105.0.
--timeout-ms[Default: 5000] The request timeout in milliseconds.
Command arguments:
worker-key[Optional] The worker key. If not provided, it will be read from the manifest.json in the current directory.

Undeploy JFrog Worker Example

Undeploy a worker named my-worker from an Artifactory instance identified by my-server.

jf worker undeploy --server-id my-server my-worker

--format json output

jf worker undeploy --server-id my-server my-worker --format json
{
  "status_code": 200,
  "message": "OK"
}

Execute an HTTP-Triggered Worker

Execute an HTTP-triggered worker.

ParameterCommand / Description
Command nameworker execute
Abbreviationworker exec, worker e
Command options:
--server-id[Optional] Server ID configured using the config command.
--format[Default: json] Output format. Supported values: json, table. Available from JFrog CLI 2.105.0.
--timeout-ms[Default: 5000] The request timeout in milliseconds.
--project-key[Optional] The key of the project that the worker belongs to.
Command arguments:
worker-keyThe worker key. If not provided it will be read from the manifest.json in the current directory.
json-payloadThe json payload expected by the worker. Use - to read the payload from standard input. Use @<file-path> to read from a file located at <file-path>.

Execute an HTTP-Triggered Worker Example

Execute an HTTP-triggered worker initialized in the current directory, with a payload located in a file named payload.json from the same directory.

jf worker execute @payload.json

Execute an HTTP-triggered worker with a payload from the standard input.

jf worker execute - <<EOF
{
  "a": "key",
  "an-integer": 14
}
EOF

Execute an HTTP-triggered worker by providing the payload as an argument.

jf worker execute '{"my":"payload"}'

--format json output (default)

{
  "key": "my-worker",
  "workerKey": "my-worker",
  "triggeredByEvent": "BEFORE_DOWNLOAD",
  "statusCode": 200,
  "status": "STATUS_SUCCESS",
  "warnings": [],
  "errors": [],
  "debug": []
}

--format table output

jf worker execute @payload.json --format table
key          workerKey   triggeredByEvent   statusCode  status          warnings  errors  debug
my-worker    my-worker   BEFORE_DOWNLOAD    200         STATUS_SUCCESS

List Available Events

This command lists all the available events on the platform. Without --format, the output is a plain comma-separated list of action names, kept for backward compatibility. Use --format table or --format json for structured output.

ParameterCommand / Description
Command nameworker list-event
Abbreviationworker le
Command options:
--server-id[Optional] Server ID configured using the config command.
--format[Optional] Output format. Supported values: table, json. Available from JFrog CLI 2.105.0.
--timeout-ms[Default: 5000] The request timeout in milliseconds.
--project-key[Optional] List events available to a specific project.

List Available Events Example

List events supported by a server identified by my-server.

jf worker list-event --server-id my-server

Output without --format (default)

BEFORE_DOWNLOAD, AFTER_CREATE, GENERIC_EVENT

--format table output

jf worker list-event --server-id my-server --format table
NAME                  APPLICATION   DESCRIPTION
BEFORE_DOWNLOAD       artifactory   Triggered before a download request is fulfilled
AFTER_CREATE          artifactory   Triggered after an artifact is created
GENERIC_EVENT         artifactory   Triggered on demand via `jf worker execute`

--format json output

jf worker list-event --server-id my-server --format json
[
  {
    "action": {
      "application": "artifactory",
      "name": "BEFORE_DOWNLOAD"
    },
    "description": "Triggered before a download request is fulfilled",
    "typesDefinitions": "..."
  }
]

List Registered Workers

List workers saved on your Artifactory instance. The default output is a table (CSV) with columns name, action, description, enabled, sorted by worker name. Use --format json for full JSON output.

⚠️

Warning

The --json boolean flag is deprecated as of JFrog CLI 2.105.0 and replaced by --format json. It still works but prints a deprecation warning. If your scripts use --json, update them to use --format json.

ParameterCommand / Description
Command nameworker list
Abbreviationworker ls
Command options:
--server-id[Optional] Server ID configured using the config command.
--format[Default: table] Output format. Supported values: table, json. Available from JFrog CLI 2.105.0.
--timeout-ms[Default: 5000] The request timeout in milliseconds.
--project-key[Optional] List the events created in a specific project.
Command arguments:
action[Optional] Only show workers of this type. To have the list of all available actions use jf worker list-event.

List Registered Workers Example

List all workers registered in a platform named my-platform.

jf worker list --server-id my-platform

--format table output (default)

my-worker,BEFORE_DOWNLOAD,Intercepts download requests,true
another-worker,AFTER_CREATE,Post-creation hook,false

--format json output

jf worker list --server-id my-platform --format json
{
  "workers": [
    {
      "key": "my-worker",
      "description": "Intercepts download requests",
      "debug": false,
      "enabled": true,
      "sourceCode": "...",
      "action": "BEFORE_DOWNLOAD",
      "secrets": [],
      "projectKey": ""
    },
    {
      "key": "another-worker",
      "description": "Post-creation hook",
      "debug": false,
      "enabled": false,
      "sourceCode": "...",
      "action": "AFTER_CREATE",
      "secrets": [],
      "projectKey": ""
    }
  ]
}

Show Worker Execution History

Display the execution history of a specific worker.

ParameterCommand / Description
Command nameworker execution-history
Abbreviationworker exec-hist, worker eh
Command options:
--server-id[Optional] Server ID configured using the config command.
--format[Default: json] Output format. Supported values: json, table. Available from JFrog CLI 2.105.0.
--timeout-ms[Default: 5000] The request timeout in milliseconds.
--project-key[Optional] List events available to a specific project.
--with-test-runs[Default: false] Whether to include test-runs entries.
Command arguments:
worker-key[Optional] The worker key. If not provided, it will be read from the manifest.json in the current directory.

Show Worker Execution History Example

Retrieves the execution history of a worker named my-worker, including test runs.

jf worker execution-history --with-test-runs my-worker

--format json output (default)

[
  {
    "workerKey": "my-worker",
    "workerType": "BEFORE_DOWNLOAD",
    "workerProjectKey": "",
    "executionStatus": "STATUS_SUCCESS",
    "startTimeMillis": 1730460000000,
    "endTimeMillis": 1730460001234,
    "triggeredBy": "[email protected]",
    "testRun": false,
    "executedVersion": "3",
    "traceId": "abc123def456"
  }
]

--format table output

jf worker execution-history --with-test-runs my-worker --format table
Worker Key   Worker Type       Project Key  Status          Started At            Ended At              Triggered By          Test Run  Executed Version  Trace ID
my-worker    BEFORE_DOWNLOAD                STATUS_SUCCESS  2024-11-01T12:00:00Z  2024-11-01T12:00:01Z  [email protected]      false     3                 abc123def456

Edit Worker Schedule

Edit the manifest of a SCHEDULED_EVENT worker to update the schedule criteria.

Deploy the worker afterward with jf worker deploy for the change to be applied to the server.

ParameterCommand / Description
Command nameworker edit-schedule
Abbreviationworker es
Command options:
--cron[Mandatory] A standard cron expression with minutes resolution. Seconds resolution is not supported by Worker service.
--timezone[Default: UTC] The timezone to use for scheduling.

Edit Worker Schedule Example

Edit a worker manifest so that it is executed every minute.

jf worker edit-schedule --cron "* * * * *"

Frequently Asked Questions

This section provides answers to frequently asked questions.

plusFAQs
Q: How do I initialize a new JFrog Worker from the command line?

A: Run jf worker init <action> <worker-name>, using an action from jf worker list-event. This generates the Worker's manifest.json, worker.ts, and other project files. See Initialize JFrog Worker.

Q: What happens if I use the deprecated --json flag with jf worker list?

A: --json is deprecated but still works with a warning. Use --format json instead. See List Registered Workers.

Q: What is the difference between jf worker execute and jf worker test-run?

A: jf worker test-run runs the Worker using its local content, so you can test changes before pushing them to the server. jf worker execute runs the HTTP-triggered worker command itself. See Test-Run JFrog Worker and Execute an HTTP-Triggered Worker.

Q: What do I need before I can test-run a JFrog Worker?

A: Initialize the Worker first with jf worker init. See Initialize JFrog Worker.

Q: Can I schedule a JFrog Worker to run automatically?

A: Yes. Use jf worker edit-schedule --cron to set a cron expression on a SCHEDULED_EVENT worker. See Edit Worker Schedule.

Related Topics


Did this page help you?