Skip to content

Commit

Permalink
Add worker-cli documentation (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehl-jf authored Aug 12, 2024
1 parent 28d5fe5 commit 8642445
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CLI for JFrog Platform Services

This page describes how to use JFrog CLI with JFrog Platform Services.

Read more about JFrog CLI [here](https://jfrog-external.fluidtopics.net/r/help/JFrog-CLI/JFrog-CLI).

**Managing Workers**

JFrog CLI allows you to fully manage your platform workers.


Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Add worker secret

## Overview

This command is used to edit a worker manifest to add secret that can be used for deployment or/and execution.

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

## Example

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

```
jfrog worker add-secret my-secret
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Deploy a worker

## Overview

This command is used to update the worker definition (code, description , filter, secret ...) on your Artifactory instance.

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

## Example

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

```
jfrog worker server deploy --server-id my-server
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Test a worker

## Overview

Dry run a worker. The worker needs to be initialized before running this command.

| | |
|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| Command name | worker dry-run |
| Abbreviation | worker dr |
| **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 <file-path>. |

## Example

Dry run a worker initialized in the current directory, with a payload located in a file named `payload.json` from the same directory.

```
jfrog worker dry-run @payload.json
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Execute an HTTP-triggered worker

## Overview

Execute an HTTP-triggered worker.

| | |
|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| 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. |
| **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 <file-path>. |

## 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
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Initialize a Worker

## Overview

This command is used to initialize a new platform worker.

| | |
|------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Command name | worker init |
| Abbreviation | worker i |
| **Command options:** | |
| `--force` | \[Default: false] Whether to overwrite existing files. |
| `--no-test` | \[Default: false] Whether to skip tests generation. |
| **Command arguments:** | |
| action | The action that will trigger the worker (BEFORE_DOWNLOAD, AFTER_DOWNLOAD, BEFORE_UPLOAD, AFTER_CREATE, AFTER_BUILD_INFO_SAVE, AFTER_MOVE, GENERIC_EVENT, BEFORE_CREATE_TOKEN, ...). |
| worker-name | The name of the worker |

## Example

Initialize a new BEFORE_DOWNLOAD worker named `my-worker`.

```
jfrog worker init BEFORE_DOWNLOAD my-worker
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# List events

## Overview

This command list all the available events on your Artifactory.

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

## Example

List event supported by a server identified by `my-server`.

```
jfrog worker list-event --server-id my-server
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# List registered workers

## Overview

List workers saved on your Artifactory instance. The default output is a CSV format with columns `name`,`action`,`description`,`enabled`.

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


# Example

List all workers registered in a platform named `my-platform` with detailed data.

```
jfrog worker list --server-id my-platform --json
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Undeploy a worker

## Overview

This command is used to remove a registered worker from you Artifactory instance.

| | |
|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 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. |
| **Command arguments:** | |
| worker-key | \[Optional] The worker key. If not provided it will be read from the `manifest.json` in the current directory. |

## Example

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

```
jfrog worker undeploy --server-id my-server my-worker
```

0 comments on commit 8642445

Please sign in to comment.