dolphinscheduler api 创建工作流
时间: 2024-05-16 12:08:41 浏览: 236
dolphinscheduler:Apache DolphinScheduler是一个具有功能强大的DAG可视界面的分布式可扩展工作流调度程序平台,致力于解决数据管道中的复杂作业依赖关系,并提供各种可用的开箱即用的作业。
以下是使用DolphinScheduler API创建工作流的步骤:
1.登录DolphinScheduler并获取到登录凭证token。
2.创建工作流定义,包括工作流名称、描述、版本号、租户ID等信息。请求示例:
```shell
POST /dolphinscheduler/projects/{projectName}/processes HTTP/1.1
Host: dolphinscheduler-server-host:port
Content-Type: application/json
Authorization: Bearer token
{
"processDefinition": {
"name": "test_workflow",
"description": "test_workflow_description",
"locations": [
{
"name": "shell"
}
],
"tasks": [
{
"name": "task_1",
"description": "task_1_description",
"type": "SHELL",
"params": {
"rawScript": "echo 'hello world'"
},
"preTasks": [],
"postTasks": []
},
{
"name": "task_2",
"description": "task_2_description",
"type": "SHELL",
"params": {
"rawScript": "echo 'hello world'"
},
"preTasks": [
{
"name": "task_1",
"type": "SHELL"
}
],
"postTasks": []
},
{
"name": "task_3",
"description": "task_3_description",
"type": "SHELL",
"params": {
"rawScript": "echo 'hello world'"
},
"preTasks": [
{
"name": "task_2",
"type": "SHELL"
}
],
"postTasks": []
}
],
"timeout": {
"strategy": "FAILED",
"interval": 1,
"enable": false
},
"tenantId": 1,
"receivers": "",
"receiversCc": "",
"warningType": "NONE",
"processInstancePriority": "MEDIUM",
"workerGroupId": -1,
"timeoutFlag": false,
"taskRetryTimes": 0,
"retryInterval": 1,
"runFlag": "NORMAL",
"dependence": {
"relation": "AND",
"dependTaskList": []
},
"globalParams": []
},
"releaseState": "ONLINE"
}
```
3.创建工作流实例,即启动工作流。请求示例:
```shell
POST /dolphinscheduler/projects/{projectName}/processes/{processDefinitionId}/start-time HTTP/1.1
Host: dolphinscheduler-server-host:port
Content-Type: application/json
Authorization: Bearer token
{
"scheduleTime": "2022-01-01 00:00:00",
"failureStrategy": "END",
"startNodeList": [
{
"name": "task_1",
"type": "SHELL"
}
],
"taskDependType": "ALL_SUCCESS",
"timeout": {
"strategy": "FAILED",
"interval": 1,
"enable": false
},
"workerGroupId": -1,
"processInstancePriority": "MEDIUM",
"warningType": "NONE",
"startParams": "",
"runMode": "NORMAL",
"environmentParams": "",
"globalParams": []
}
```
4.查询工作流实例状态。请求示例:
```shell
GET /dolphinscheduler/projects/{projectName}/processes/{processInstanceId}/status HTTP/1.1
Host: dolphinscheduler-server-host:port
Content-Type: application/json
Authorization: Bearer token
```
阅读全文