操作方法:管理 Orchestrator 资源
用于使用“uip 或”管理 Orchestrator Runtime 资源的日常任务,包括资产、存储桶、库、队列、触发器和 Webhook。
uip or是 Orchestrator 运行时资源上的通用 CRUD 表面:资产、存储桶(以及其中包含的文件)、库、队列(和项目)、触发器和 Webhook ,以及本指南以 。此页面收集每天出现的任务(批量创建资产、将文件移入和移出存储桶、调度队列工作、检查触发器),作为可复制粘贴的代码片段。
每个子命令的完整标志列表位于uip or参考页面及其每个资源的页面上。本页介绍常见的使用模式。
uip or(本页面)与 uip solution resource 不同。 uip or 始终在实时租户上调用 Orchestrator。uip solution resource只会读取磁盘上.uipx解决方案中的本地资源声明。如有疑问,请查看前缀。
您需要首先了解的约定
在任何代码片段生效之前:
- 身份验证。每个
uip or动词都会调用 Orchestrator。请先运行uip login。运行uip login tenant set <name>以切换活动租户,然后再针对不同租户进行调用。 - 文件夹作用域。资产、存储桶、队列、队列项目和时间/队列触发器为文件夹作用域— 传递
--folder-path(例如Shared)或--folder-key(GUID) 或--all-folders(如果支持该标志)。库、API 触发器和 Webhook 是租户作用域,会拒绝文件夹标志。 - 键。列表动词返回 GUID(
key、identifier和uniqueKey)。将这些值传递给get、update和delete。数字id字段为内部字段;不要将其传递给命令。 - 破坏性运算需要
-y, --yes。如果没有它,这些资源上的每个delete动词都将无法运行 — CLI 从不以交互方式提示。 - JSON 是默认输出。下面的每个代码片段均依赖于此;请参阅输出格式。
资产
从 CSV 中批量部署资产
这是最常见的“管理我的密码和配置”任务。给定一个如下的 CSV:
name,value,type,folderPath
ApiEndpoint,https://api.example.com,Text,Shared
MaxRetries,3,Integer,Shared
Debug,false,Bool,Shared
name,value,type,folderPath
ApiEndpoint,https://api.example.com,Text,Shared
MaxRetries,3,Integer,Shared
Debug,false,Bool,Shared
使用普通的 bash + uip or assets create遍历它:
#!/usr/bin/env bash
set -euo pipefail
# Skip the header row
tail -n +2 ./assets.csv | while IFS=, read -r name value type folder; do
uip or assets create "$name" "$value" \
--folder-path "$folder" \
--type "$type"
done
#!/usr/bin/env bash
set -euo pipefail
# Skip the header row
tail -n +2 ./assets.csv | while IFS=, read -r name value type folder; do
uip or assets create "$name" "$value" \
--folder-path "$folder" \
--type "$type"
done
对同一文件夹重新运行此方法将无法处理重复项。有两种处理方法:
-
更新插入模式。先列出,然后每行
create或update:tail -n +2 ./assets.csv | while IFS=, read -r name value type folder; do existing=$(uip or assets list --folder-path "$folder" --name "$name" \ --output-filter "Data[?name=='$name'] | [0].key" --output plain) if [ -n "$existing" ] && [ "$existing" != "null" ]; then uip or assets update "$existing" "$value" else uip or assets create "$name" "$value" --folder-path "$folder" --type "$type" fi donetail -n +2 ./assets.csv | while IFS=, read -r name value type folder; do existing=$(uip or assets list --folder-path "$folder" --name "$name" \ --output-filter "Data[?name=='$name'] | [0].key" --output plain) if [ -n "$existing" ] && [ "$existing" != "null" ]; then uip or assets update "$existing" "$value" else uip or assets create "$name" "$value" --folder-path "$folder" --type "$type" fi done -
解决方案部署模式。对于与包一起发布的资产集,请在解决方案清单文件中声明它们并使用
uip solution deploy run --config-file——该路径在设计上即为幂等。请参阅操作方法:打包和发布解决方案。
凭据类型资产
凭据和密码资产需要凭据存储密钥:
# Find the credential store
STORE_KEY=$(uip or credential-stores list \
--output-filter "Data[?name=='MyStore'] | [0].key" --output plain)
# Create the credential asset (value format: username:password)
uip or assets create ApiLogin "alice:s3cr3t" \
--folder-path Shared \
--type Credential \
--credential-store-key "$STORE_KEY"
# Find the credential store
STORE_KEY=$(uip or credential-stores list \
--output-filter "Data[?name=='MyStore'] | [0].key" --output plain)
# Create the credential asset (value format: username:password)
uip or assets create ApiLogin "alice:s3cr3t" \
--folder-path Shared \
--type Credential \
--credential-store-key "$STORE_KEY"
list或get从不会返回凭据和密码值;使用assets get-asset-value (仍需要文件夹作用域)读取实时值,或通过机器人调用。
跨文件夹共享资产
在Shared中创建一次,然后共享到每个需要的文件夹:
ASSET_KEY=$(uip or assets list --folder-path Shared --name ApiEndpoint \
--output-filter "Data[0].key" --output plain)
for folder in Production Staging Development; do
uip or assets share "$ASSET_KEY" --folder-path "$folder"
done
ASSET_KEY=$(uip or assets list --folder-path Shared --name ApiEndpoint \
--output-filter "Data[0].key" --output plain)
for folder in Production Staging Development; do
uip or assets share "$ASSET_KEY" --folder-path "$folder"
done
使用unshare撤销。有关完整的动词列表,请参阅资产。
存储桶和存储桶文件
上传本地文件
BUCKET_KEY=$(uip or buckets list --folder-path Shared \
--output-filter "Data[?name=='invoices'] | [0].key" --output plain)
uip or bucket-files upload "$BUCKET_KEY" "inbox/invoice-001.pdf" \
--folder-path Shared \
--file ./invoice-001.pdf
BUCKET_KEY=$(uip or buckets list --folder-path Shared \
--output-filter "Data[?name=='invoices'] | [0].key" --output plain)
uip or bucket-files upload "$BUCKET_KEY" "inbox/invoice-001.pdf" \
--folder-path Shared \
--file ./invoice-001.pdf
存储桶 ( inbox/invoice-001.pdf ) 内的路径是upload的第二个参数; --file是要上传的本地路径。内容类型为自动检测;传递--content-type进行覆盖。
下载文件
uip or bucket-files download "$BUCKET_KEY" "reports/summary.csv" \
--folder-path Shared \
--destination ./summary.csv
uip or bucket-files download "$BUCKET_KEY" "reports/summary.csv" \
--folder-path Shared \
--destination ./summary.csv
如果没有--destination ,内容将流式传输到标准输出 — 通过管道输入到处理器非常有用。
列出并分页
# First page
uip or bucket-files list "$BUCKET_KEY" --folder-path Shared
# The response carries a continuationToken — pass it back to fetch the next page
uip or bucket-files list "$BUCKET_KEY" --folder-path Shared \
--continuation-token "<token-from-previous-response>"
# First page
uip or bucket-files list "$BUCKET_KEY" --folder-path Shared
# The response carries a continuationToken — pass it back to fetch the next page
uip or bucket-files list "$BUCKET_KEY" --folder-path Shared \
--continuation-token "<token-from-previous-response>"
存储桶文件列表是 CLI 中使用继续令牌而不是偏移量分页的一个资源,其他列表动词使用--limit / --offset 。
预签名 URL
如果机器人或外部服务需要在不通过 CLI 的情况下直接访问 Blob:
uip or bucket-files get-upload-url "$BUCKET_KEY" "inbox/incoming.pdf" \
--folder-path Shared --expiry-in-minutes 30
uip or bucket-files get-download-url "$BUCKET_KEY" "reports/summary.csv" \
--folder-path Shared --expiry-in-minutes 30
uip or bucket-files get-upload-url "$BUCKET_KEY" "inbox/incoming.pdf" \
--folder-path Shared --expiry-in-minutes 30
uip or bucket-files get-download-url "$BUCKET_KEY" "reports/summary.csv" \
--folder-path Shared --expiry-in-minutes 30
两者都会返回限定于单个文件路径的限时 URL。
队列和队列项目
创建队列
uip or queues create InvoiceQueue \
--folder-path Shared \
--max-retries 3 \
--retention-period 90
uip or queues create InvoiceQueue \
--folder-path Shared \
--max-retries 3 \
--retention-period 90
队列引用上的完整标志列表 — --auto-retry 、 --enforce-unique-reference 、 --encrypted ,保留设置 — 。
添加单个工作项目
uip or queue-items add InvoiceQueue \
--folder-path Shared \
--specific-content '{"InvoiceId":"INV-001","Amount":1500}' \
--priority High
uip or queue-items add InvoiceQueue \
--folder-path Shared \
--specific-content '{"InvoiceId":"INV-001","Amount":1500}' \
--priority High
--specific-content是将机器人将读取的 JSON 有效负载。
从文件批量添加
cat > ./items.json <<'EOF'
[
{"specificContent": {"InvoiceId":"INV-001"}, "priority": "Normal"},
{"specificContent": {"InvoiceId":"INV-002"}, "priority": "Normal"}
]
EOF
ITEMS=$(jq -c . ./items.json)
uip or queue-items bulk-add InvoiceQueue \
--folder-path Shared \
--queue-items "$ITEMS" \
--commit-type StopOnFirstFailure
cat > ./items.json <<'EOF'
[
{"specificContent": {"InvoiceId":"INV-001"}, "priority": "Normal"},
{"specificContent": {"InvoiceId":"INV-002"}, "priority": "Normal"}
]
EOF
ITEMS=$(jq -c . ./items.json)
uip or queue-items bulk-add InvoiceQueue \
--folder-path Shared \
--queue-items "$ITEMS" \
--commit-type StopOnFirstFailure
每个项目接受 specificContent、priority、reference、deferDate、dueDate — 没有每个项目的队列名称;队列是由整个批次共享的单个位置参数(上述 InvoiceQueue)。
--commit-type用于控制当一行验证失败时会发生的情况: ProcessAllIndependently (默认)、 StopOnFirstFailure或AllOrNothing 。
检查失败的项目
uip or queue-items list --folder-path Shared \
--queue-name InvoiceQueue \
--status Failed \
--output-filter "Data[].{key:uniqueKey, ref:reference, reason:processingException}"
uip or queue-items list --folder-path Shared \
--queue-name InvoiceQueue \
--status Failed \
--output-filter "Data[].{key:uniqueKey, ref:reference, reason:processingException}"
对单个uniqueKey使用queue-items get-history ,查看其完整的状态转换历史记录,这有助于诊断重试循环。
标记失败的项目以供重试
uip or queue-items set-review-status Retried \
"<queue-item-key-1>" "<queue-item-key-2>"
uip or queue-items set-review-status Retried \
"<queue-item-key-1>" "<queue-item-key-2>"
set-review-status采用Retried 、 Abandoned和Deleted之一。
触发器
列出文件夹中的触发器
uip or triggers list --type time --folder-path Shared --enabled \
--output-filter "Data[].{name:name, cron:startProcessCron, enabled:isEnabled}"
uip or triggers list --type time --folder-path Shared --enabled \
--output-filter "Data[].{name:name, cron:startProcessCron, enabled:isEnabled}"
三种触发器类型: time 、 queue和api 。为每个动词传递--type (默认为time )。API 触发器是租户作用域 — 省略--folder-path 。
创建时间触发器
RELEASE_KEY=$(uip or processes list --folder-path Shared --name InvoiceProcessing \
--output-filter "Data[0].Key" --output plain)
uip or triggers create --type time \
--name NightlyInvoices \
--release-key "$RELEASE_KEY" \
--runtime-type Unattended \
--job-priority Normal \
--folder-path Shared \
--cron "0 0 2 * * ?" \
--time-zone UTC
RELEASE_KEY=$(uip or processes list --folder-path Shared --name InvoiceProcessing \
--output-filter "Data[0].Key" --output plain)
uip or triggers create --type time \
--name NightlyInvoices \
--release-key "$RELEASE_KEY" \
--runtime-type Unattended \
--job-priority Normal \
--folder-path Shared \
--cron "0 0 2 * * ?" \
--time-zone UTC
--cron值使用 Quartz 的 6 字段格式 ( sec min hour dayOfMonth month dayOfWeek ),而不是标准 CRON。"0 0 2 * * ?"是“每天 02:00”。
启用或禁用触发器
没有专用的 enable/disable 命令 — 通过 update 切换触发器:
uip or triggers update <trigger-key> --type time --folder-path Shared --disabled
uip or triggers update <trigger-key> --type time --folder-path Shared --enabled
uip or triggers update <trigger-key> --type time --folder-path Shared --disabled
uip or triggers update <trigger-key> --type time --folder-path Shared --enabled
使用triggers history诊断未触发的触发器 — 触发日志显示许可证缺失、计算机不可用以及其他上游块。
Webhooks
Webhook 在租户范围内。创建一次,即可在租户中发生每个匹配事件时触发 Webhook:
uip or webhooks create JobAlerts \
--url https://hooks.example.com/uipath \
--events "job.completed,job.faulted" \
--secret "$WEBHOOK_SECRET"
uip or webhooks create JobAlerts \
--url https://hooks.example.com/uipath \
--events "job.completed,job.faulted" \
--secret "$WEBHOOK_SECRET"
列出租户可用的事件类型:
uip or webhooks event-types
uip or webhooks event-types
无需等待真实事件发生即可测试交付:
uip or webhooks ping <webhook-key>
uip or webhooks ping <webhook-key>
库
库是租户范围内的(而非文件夹范围)— 它们位于租户订阅源中,并由包 ID 引用,例如MyLib:1.0.0 :
# Upload a new version
uip or libraries upload --file ./MyLib.1.0.0.nupkg
# See all versions of a package
uip or libraries versions MyLib
# Download a specific version
uip or libraries download MyLib:1.0.0 --destination ./MyLib.1.0.0.nupkg
# Upload a new version
uip or libraries upload --file ./MyLib.1.0.0.nupkg
# See all versions of a package
uip or libraries versions MyLib
# Download a specific version
uip or libraries download MyLib:1.0.0 --destination ./MyLib.1.0.0.nupkg
密钥采用PackageId:Version格式,而非 GUID。
脚本编写提示
- 将单个值提供给变量时,请始终传递
--output-filter。它避免了脆弱的jq调用,并在 CLI 解析时进行验证 — 请参阅脚本模式。 - 列表动词返回分页结果— 对于大多数结果,
--limit/--offset,对于存储桶文件,--continuation-token。0中仍出现空结果(Data中的零行) — 列表查询成功;未找到匹配项。 - 大多数更新/删除动词都是跨文件夹的—
uip or中每个动词部分上的标志表格都有明确说明(“跨文件夹”)。只有create和列表需要这些资源的文件夹作用域。
另请参阅
uip or参考— 授权的逐动词标记列表。此页面上的每个代码片段都链接回匹配的部分。uip solution deploy config link— 将解决方案声明的资源绑定到您使用uip or创建的资源。- 脚本模式— 轮询、在退出
2重试、幂等管道。 - 操作方法:打包并发布解决方案— 随包一起提供的资源的替代路径。