- 概述
- 开始使用
- 概念
- 使用 UiPath CLI
- 操作指南
- CI/CD 方法
- 命令参考
- 迁移
- 参考与支持
uip 函数
“uip 函数”的语法和选项,该函数可构建、提供、运行和发布 UiPath JS/TS 和 Python 函数。
uip function用于构建、提供和发布UiPath Functions— 在 UiPath 平台上打包并运行的小型 JS/TS 或 Python 处理程序。uip function是规范组名称; uip functions (复数)已接受为别名。
概念
- 一个命令组。
uip function涵盖两种语言。它会从当前目录中的uipath.json、package.json或pyproject.toml,或-l中new--language检测项目的语言,并运行匹配的 JS/TS 或 Python 工具。未在此页面上列出的选项将传递给该工具,例如uip function serve --production。 - Language resolution matters for
initandnew.initruns for the language of the project in the current directory, and fails when it detects none.newauto-detects; when detection is inconclusive, it defaults to TypeScript with a logged warning, unless you pass--language js|ts|py/python. setup验证工具链。对于 JS/TS 项目,它检查 Node.js ≥20,对于 Python 项目,检查带有uipath包的 Python。在new转发到 JS/TS CLI 之前,Node.js 检查也会自动运行。在配置 Python 之前,Python 函数命令将失败,并且ConfigError指向uip function setup。publishvs.pushtarget different destinations:publishuploads the packed.nupkgto an Orchestrator feed;pushsyncs the project directly into a Studio Web project. Both accept--url/--org/--token(or the matchingUIPATH_URL/UIPATH_ORGANIZATION_NAME/UIPATH_ACCESS_TOKENenv vars). On a JS/TS project without--token, both use the session created byuip login.- Solution auto-registration. A successful
initauto-registers the project into a parent.uipxsolution when one exists (same pattern asagent/case/flowinit) — pass--skip-solution-registrationto opt out. This reports via a separateFunctionsInitSolutionRegistrationsuccess envelope after the underlying CLI's own init output.initdoes not create a solution when none exists.
大纲
uip function setup [--force]
uip function new [name] [--name <name>] [-l, --language ts|js|py] [--empty] [--kind job|http]
uip function init [--language ts|js|py] [--skip-solution-registration]
uip function serve [--port <port>] [--runtime node|deno]
uip function run [name] [--input <json>] [--input-file <path>]
uip function pack
uip function push [--url <url>] [--project-id <id>] [--org <org>] [--token <token>]
uip function publish [--url <url>] [--org <org>] [--token <token>] [--feed-id <id>]
uip function runtime-install [--path <folder>]
uip function setup [--force]
uip function new [name] [--name <name>] [-l, --language ts|js|py] [--empty] [--kind job|http]
uip function init [--language ts|js|py] [--skip-solution-registration]
uip function serve [--port <port>] [--runtime node|deno]
uip function run [name] [--input <json>] [--input-file <path>]
uip function pack
uip function push [--url <url>] [--project-id <id>] [--org <org>] [--token <token>]
uip function publish [--url <url>] [--org <org>] [--token <token>] [--feed-id <id>]
uip function runtime-install [--path <folder>]
uip 函数设置
验证 Functions 项目所需的工具链:对于 JS/TS,使用 Node.js v20 或更高版本;对于 Python,使用uipath包验证 Python。如果 Node.js 缺失或过期,则命令会失败,并显示ConfigError 。若缺少 Python 配置,系统会报告该问题,但不会导致命令失败,因此不会阻止仅使用 JS/TS 的计算机。结果会缓存并与uip codedagent setup共享,因此运行任一命令都会为两者配置 Python。
选项
| 长 | 值 | 描述 |
|---|---|---|
--force | 标记 | 即使存在缓存结果,也请重新运行验证。默认值: false 。 |
示例
uip function setup --force
uip function setup --force
新的 uip 函数
搭建一个新的 Functions 项目,默认情况下包含 Hello World 函数。
参数
| 名称 | 必填 | 用途 |
|---|---|---|
[name] | 否 | 项目名称/目录。默认 my-functions。也可以作为 --name 传递。 |
选项
| 长 | 值 | 描述 |
|---|---|---|
--name <name> | 字符串 | 位置参数的替代方法。 |
-l, --language <lang> | ts (默认)| js | py/python | 项目语言。 |
--empty | 标记 | 跳过 json 函数 — 空项目。仅限 JS/TS。 |
--kind <kind> | job (默认) | http | job (作业函数, targetRuntime javascript )或http (HTTP 函数, javascript-server )。仅限 JS/TS。 |
JS/TS scaffolds into a new ./<name> directory. Python scaffolds into the current directory, with one exception: from a solution root, a directory that holds a .uipx file, it scaffolds into ./<name>, so the project becomes a member folder of the solution. Only the current directory is checked for a .uipx file.
From a solution root, a <name> that already exists is refused with Result: ValidationError and exit code 3, and nothing is written. To choose the directory, pass --dir <path>, which is forwarded to the Python CLI unchanged.
示例
uip function new my-fn --language ts
uip function new my-fn --language py
uip function new my-endpoint --language ts --kind http
uip function new my-fn --language ts
uip function new my-fn --language py
uip function new my-endpoint --language ts --kind http
数据形状(--输出 json)
{ "Code": "NewComplete", "Data": { "Message": "Project created at ./my-fn" } }
{ "Code": "NewComplete", "Data": { "Message": "Project created at ./my-fn" } }
uip 函数初始化
Write the project files for the project in the current directory:
- Python: discover entrypoints and (re)generate
entry-points.json/bindings.json/project.uiproj. Must run beforepack/pushfor a Python project. - JS/TS: make an existing folder of functions a project.
initwritesuipath.json, with the functions found underfunctions/, andproject.uiproj, where they are missing.
init fails when it detects no project language in the current directory.
选项
| 长 | 值 | 描述 |
|---|---|---|
--language <lang> | ts | js | py | Force the language when detection would otherwise be ambiguous. |
--skip-solution-registration | 标记 | 不要在父级 .uipx 解决方案中自动注册项目。 |
示例
uip function init
uip function init
数据形状(--输出 json)
{ "Code": "InitComplete", "Data": { "Message": "Project initialized." } }
{ "Code": "InitComplete", "Data": { "Message": "Project initialized." } }
随后报告解决方案注册第二次成功:
{
"Code": "FunctionsInitSolutionRegistration",
"Data": { "SolutionRegistration": { "Status": "Registered", "...": "..." } }
}
{
"Code": "FunctionsInitSolutionRegistration",
"Data": { "SolutionRegistration": { "Status": "Registered", "...": "..." } }
}
当不存在父解决方案时,SolutionRegistration.Status 为 "NotInSolution",当 "OptedOut" 被传递时,--skip-solution-registration 为 — 始终存在,从未省略。
UIP 函数服务
使用热重载启动本地 Function Server。仅限 JS/TS。
选项
| 长 | 值 | 描述 |
|---|---|---|
--port <port> | 整数 | 要侦听的端口。默认 7070。 |
--runtime <runtime> | node (默认) | deno | 要在其中提供服务的 runtime。 |
示例
uip function serve
uip function serve
数据形状(--输出 json)
{ "Code": "ServeStarted", "Data": { "Message": "Listening on http://localhost:7070" } }
{ "Code": "ServeStarted", "Data": { "Message": "Listening on http://localhost:7070" } }
uip 函数 run
运行一个函数一次并打印其结果。函数名称来自项目的函数列表。
参数
| 名称 | 必填 | 用途 |
|---|---|---|
[name] | 否 | 要运行的函数的名称。 |
选项
| 长 | 值 | 描述 |
|---|---|---|
--input <json> | JSON | 输入有效负载。默认 {}。 |
--input-file <path> | 路径 | JSON 输入文件的路径。在 JS/TS 项目中,优先级高于--input 。 |
示例
# Python project: run the 'hello' function once with a JSON payload and read the result as JSON
uip function run hello --input '{"name":"Ada"}' --output json
# Python project: run a function with a payload kept in a file
uip function run hello --input-file ./payload.json --output json
# Python project: run the 'hello' function once with a JSON payload and read the result as JSON
uip function run hello --input '{"name":"Ada"}' --output json
# Python project: run a function with a payload kept in a file
uip function run hello --input-file ./payload.json --output json
数据形状(--输出 json)
{ "Code": "RunComplete", "Data": { "message": "Hello, Ada!" } }
{ "Code": "RunComplete", "Data": { "message": "Hello, Ada!" } }
当您显式传递--output json或--output yaml时,结构化结果将应用于 Python 项目:
Data是函数自己的输出,其字段名称与函数声明的名称完全相同。- 当函数返回标量、数组或不返回任何内容时,系统会将值放置在单个
Output键下。 - 进度和运行自己的日志将发送到 标准错误 (stderr) ,因此标准输出仅包含信封。
- 失败的运行将返回带有
Result: "Failure"ErrorCode: "unknown_error",并在Message中返回运行的退出代码;运行自身的错误存储在标准错误 (stderr) 中。
如果没有显式的--output json / yaml ,或者使用table或plain , run将打印基础 CLI 自己的输出。在 JS/TS 项目上, --output不支持run :CLI 打印通知,并且函数自己的输出保持不变。
uip 函数包
将项目打包到.nupkg中以进行部署。包中始终包含项目的锁定文件。
示例
uip function pack
uip function pack
数据形状(--输出 json)
{ "Code": "PackComplete", "Data": { "Message": "Package created: my-fn.0.0.1.nupkg" } }
{ "Code": "PackComplete", "Data": { "Message": "Package created: my-fn.0.0.1.nupkg" } }
uip 函数 push
将项目同步到 Studio Web — 生成入口点并上传更改的文件。
选项
| 长 | 值 | 必填 | 描述 |
|---|---|---|---|
--url <url> | url | 否 | UiPath 平台 URL。回退到 UIPATH_URL。 |
--project-id <id> | GUID | 有条件地 | “Studio Web”项目 ID。必填项,但可能来自 UIPATH_PROJECT_ID 而非标志。 |
--org <org> | 字符串 | 否 | 组织名称。回退到 UIPATH_ORGANIZATION_NAME。 |
--token <token> | 字符串 | 否 | 访问令牌。回退到 UIPATH_ACCESS_TOKEN。 |
示例
uip function push --project-id 1f2a3b4c-0000-0000-0000-000000000001
uip function push --project-id 1f2a3b4c-0000-0000-0000-000000000001
数据形状(--输出 json)
{ "Code": "PushComplete", "Data": { "Message": "Push complete." } }
{ "Code": "PushComplete", "Data": { "Message": "Push complete." } }
UIP 函数“发布”
将最新的 .nupkg 上传到 Orchestrator 文件夹。如果没有 --feed-id,将以交互方式提示输入订阅源(ESC 可取消)— CI 使用 --feed-id 跳过选取器。
选项
| 长 | 值 | 描述 |
|---|---|---|
--url <url> | url | UiPath 平台 URL。回退到 UIPATH_URL。 |
--org <org> | 字符串 | 组织名称。回退到 UIPATH_ORGANIZATION_NAME。 |
--token <token> | 字符串 | 访问令牌。回退到 UIPATH_ACCESS_TOKEN。 |
--feed-id <id> | GUID | 发布目标订阅源 — 跳过交互式选取器。 |
示例
# Interactive feed picker
uip function publish
# CI use — skip the picker
uip function publish --feed-id 9b2c1d4e-0000-0000-0000-000000000001
# Interactive feed picker
uip function publish
# CI use — skip the picker
uip function publish --feed-id 9b2c1d4e-0000-0000-0000-000000000001
数据形状(--输出 json)
{ "Code": "PublishComplete", "Data": { "Message": "Package published." } }
{ "Code": "PublishComplete", "Data": { "Message": "Package published." } }
uip 函数 runtime-install
使用自己的 package.json 创建一个运行程序文件夹,并将运行时依赖项安装到其中。仅限 JS/TS。
选项
| 长 | 值 | 描述 |
|---|---|---|
--path <folder> | 路径 | 要在其中创建和安装 runtime 依赖项的目标文件夹。 |
示例
uip function runtime-install --path .uipath/runner
uip function runtime-install --path .uipath/runner
数据形状(--输出 json)
{ "Code": "RuntimeInstallComplete", "Data": { "Message": "Runtime installed at .uipath/runner" } }
{ "Code": "RuntimeInstallComplete", "Data": { "Message": "Runtime installed at .uipath/runner" } }
错误行为
initwith no detectable language:Failure,Message: "No Functions project detected in this directory.", withInstructionsnaming--language ts|js|py.- 无法检测到的语言且没有
new的--language:默认使用 TypeScript,记录警告而非失败。 publishorpushon a JS/TS project with no login and no--token:Failure,ErrorCode: "authentication_required", exit code1, withInstructionsnaminguip loginand the--tokenalternative.- 未检测到任何其他动词的 Functions 项目:
Failure、Message: "No Functions project detected in this directory.",使用Instructions从包含uipath.json/package.json/pyproject.toml的目录运行,或显式传递--language。 - Node.js 缺失或版本低于 v20(JS/TS 路径):
ConfigError指定所需版本及安装链接。此检查在setup中运行,并在new转发到 JS/TS CLI 之前自动运行。 - 未配置 Python 或
uipath包(Python 路径):InstructionsConfigError运行uip function setup。
另请参阅
- 工具(插件)
uip codedapp— 编码应用程序的类似构建/打包/发布/推送/拉取生命周期。- 全局选项
- 退出代码
- 概念
- 大纲
- uip 函数设置
- 选项
- 示例
- 新的 uip 函数
- 参数
- 选项
- 示例
- 数据形状(--输出 json)
- uip 函数初始化
- 选项
- 示例
- 数据形状(--输出 json)
- UIP 函数服务
- 选项
- 示例
- 数据形状(--输出 json)
- uip 函数 run
- 参数
- 选项
- 示例
- 数据形状(--输出 json)
- uip 函数包
- 示例
- 数据形状(--输出 json)
- uip 函数 push
- 选项
- 示例
- 数据形状(--输出 json)
- UIP 函数“发布”
- 选项
- 示例
- 数据形状(--输出 json)
- uip 函数 runtime-install
- 选项
- 示例
- 数据形状(--输出 json)
- 错误行为
- 另请参阅