CLI for JFrog Platform Services
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. You can create workers to enhance the platform's functionality. Workers are triggered automatically by events within the JFrog Platform, which addresses specific use cases. For on-demand tasks, configure HTTP-triggered workers.
For more information about JFrog Workers.
Initialize JFrog Worker
This command is used to initialize a new JFrog worker.
| Parameter | Command / Description |
|---|---|
| Command name | worker init |
| Abbreviation | worker 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: | |
| action | The name of the action to init (eg: BEFORE_DOWNLOAD). To have the list of all available actions use jf worker list-event. |
| worker-name | The 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
BEFORE_DOWNLOAD WorkerThis 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.
| Parameter | Command / Description |
|---|---|
| Command name | worker test-run |
| Abbreviation | worker dry-run, worker dr, worker tr |
| Command options: | |
--server-id | [Optional] Server ID configured using the config command. |
--timeout-ms | [Default: 5000] The request timeout in milliseconds. |
--no-secrets | [Default: false] Do not use registered secrets. |
| Command arguments: | |
| json-payload | The json payload expected by the worker. Use - to read the payload from standard input. Use @<file-path> to read from a file located at . |
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
Deploy JFrog Worker
This command is used to update the worker definition (code, description , filter, secret ...) on your Artifactory instance.
| Parameter | Command / Description |
|---|---|
| Command name | worker deploy |
| Abbreviation | worker d |
| Command options: | |
--server-id | [Optional] Server ID configured using the config command. |
--timeout-ms | [Default: 5000] The request timeout in milliseconds. |
--no-secrets | [Default: false] Do not use registered secrets. |
Deploy JFrog Worker Example
Deploy a worker to the server with id my-server.
jf worker server deploy --server-id my-server
Add Secrets to JFrog Worker
This command is used to edit a worker manifest in order to add or edit a secret that can be used for deployment and/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.
| Parameters | Commands / Description |
|---|---|
| Command name | worker add-secret |
| Abbreviation | worker as |
| Command options: | |
--edit | [Default: false] Whether to update an existing secret. |
| Command arguments: | |
| secret-name | The 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
This command is used to remove a registered worker from you Artifactory instance.
| Parameter | Command / Description |
|---|---|
| Command name | worker undeploy |
| Abbreviation | worker rm |
| Command options: | |
--server-id | [Optional] Server ID configured using the config command. |
--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-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
Execute an HTTP-Triggered Worker
Execute an HTTP-triggered worker.
| Parameter | Command / Description |
|---|---|
| Command name | worker execute |
| Abbreviation | worker exec, worker e |
| Command options: | |
--server-id | [Optional] Server ID configured using the config command. |
--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-key | The worker key. If not provided it will be read from the manifest.json in the current directory. |
| json-payload | The json payload expected by the worker. Use - to read the payload from standard input. Use @<file-path> to read from a file located at . |
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”}’
List Available Events
This command list all the available events on the platform.
| Parameter | Command / Description |
|---|---|
| Command name | worker list-event |
| Abbreviation | worker le |
| Command options: | |
--server-id | [Optional] Server ID configured using the config command. |
--timeout-ms | [Default: 5000] The request timeout in milliseconds. |
--project-key | [Optional] List events available to a specific project. |
List Available Events Example
List event supported by a server identified by my-server.
jf worker list-event --server-id my-server
List Registered Workers
List workers saved on your Artifactory instance. The default output is a CSV format with columns name , action , description , enabled.
| Parameter | Command / Description |
|---|---|
| Command name | worker list |
| Abbreviation | worker ls |
| Command options: | |
--server-id | [Optional] Server ID configured using the config command. |
--json | [Default: false] Whether to use JSON instead of CSV as output. |
--timeout-ms | [Default: 5000] The request timeout in milliseconds. |
--project-key | [Optional] List the events created in a specific project. |
List Registered Workers Example
List all workers registered in a platform named my-platform with detailed data.
jf worker list --server-id my-platform --json
Show Worker Execution History
Display in a json format the execution history of a specific worker.
| Parameter | Command / Description |
|---|---|
| Command name | worker execution-history |
| Abbreviation | worker exec-hist, worker eh |
| Command options: | |
--server-id | [Optional] Server ID configured using the config command. |
--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
Edit Worker Schedule
Edit the manifest of a SCHEDULED_EVENT worker to update the schedule criteria.
The worker should be deploy afterward with jf worker deploy for the change to be applied to the server.
| Parameter | Command / Description |
|---|---|
| Command name | worker edit-schedule |
| Abbreviation | worker 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 "* * * * *"Updated 22 days ago
