Zadig 文档
Zadig
关于
Zadig
关于
v1.12.0
Loading...
      编辑文档
      反馈问题
      Slack 上联系我们

    本页导航

    工作流

    # 获取工作流任务状态

    # 注意事项

    • 目前仅支持 GitLab 的 commitId 查询
    • 支持完整的 commitId 或者输入 commitId 前 8 位查询

    # 请求

    GET /api/directory/workflowTask?commitId=<commitId>
    
    1

    # Query

    参数名 类型 描述 默认值 是否必须
    commitId string commitId 无 must

    # 正常返回

    [
        {
            "task_id": 49,
            "create_time": 1639466317,
            "start_time": 1639466318,
            "end_time": 1639466354,
            "status": "passed",
            "url": "http://my.zadig.com/v1/projects/detail/proxy/pipelines/multi/workflow-demo/49"
        }
    ]
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    # 返回说明

    参数名 类型 描述
    task_id int64 任务 id
    url string 任务具体 url
    status string 任务状态
    create_time int64 Unix 时间戳格式的任务创建时间
    start_time int64 Unix 时间戳格式的任务开始时间
    end_time int64 Unix 时间戳格式的任务结束时间

    任务状态包括:created(创建中)/running(运行中)/passed(通过)/failed(失败)/timeout(超时)/cancelled(取消)

    # 错误码对应列表

    
    {
    	"resultCode":401,"errorMsg":"auth failed!",
    	"resultCode":400,"errorMsg":"param is illegal!"
    }
    
    1
    2
    3
    4
    5

    # 工作流任务重试

    # 注意事项

    • 需要有执行工作流的权限
    • 支持对状态是 failed(失败)/timeout(超时)/cancelled(取消) 的工作流任务进行重试

    # 请求

    POST /api/directory/workflowTask/id/:id/pipelines/:pipelineName/restart
    
    1

    # 路径参数说明

    参数名 类型 描述 默认值 是否必须
    id int 任务 id 无 是
    pipelineName string 工作流名称 无 是

    # 正常返回

    {"message":"success"}
    
    1

    # 异常返回

    {
      "code": 6164,
      "description": "获取工作流任务失败",
      "extra": {},
      "message": "重试工作流任务失败",
      "type": "error"
    }
    
    1
    2
    3
    4
    5
    6
    7

    # 取消工作流任务

    # 注意事项

    • 需要有执行工作流的权限;

    # 请求

    POST /api/directory/workflowTask/id/:id/pipelines/:pipelineName/cancel
    
    1

    # 路径参数说明

    参数名 类型 描述 默认值 是否必须
    id int 任务 id 无 是
    pipelineName string 工作流名称 无 是

    # 正常返回

    {"message":"success"}
    
    1

    # 异常返回

    {
      "code": 6163,
      "description": "mongo: no documents in result",
      "extra": {},
      "message": "取消工作流任务失败",
      "type": "error"
    }
    
    1
    2
    3
    4
    5
    6
    7

    # 执行工作流

    # 注意事项

    • 需要有执行工作流的权限;
    • 暂不支持更新环境变量;
    • 暂不支持高级选项,如工作流空间缓存和 Docker 缓存。

    # 请求

    POST /api/directory/workflowTask/create
    
    1

    # body 参数样例

    {
        "workflow_name":"autoproject-workflow-dev",
        "env_name":"dev",    
        "release_images": [
            {                    
                "image": "ccr.ccs.tencentyun.com/trial/go-sample-site1:20211221120415-1-main",
                "service_name": "gss",
                "service_module": "go-sample-site1"
            },
            {                    
                "image": "ccr.ccs.tencentyun.com/trial/go-sample-site2:20211221120415-1-main",
                "service_name": "gss",
                "service_module": "go-sample-site2"
            }
        ],
        "targets":[
            {
                "name":"redis3",
                "service_type": "k8s",
                "build":{
                    "repos":[
                        {
                            "repo_name":"voting-app",
                            "branch":"master",
                            "pr":0
                        },
                        {
                            "repo_name":"zadig-infra",
                            "branch":"master",
                            "pr":5
                        }
                    ]
                }
            }
        ],
        "callback": {
            "callback_url": "https://callbackhost.com/callback",
            "callback_vars": {
                "k1": 1,
                "k2": "value2"
            }
        }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43

    # body 参数说明

    参数名 类型 描述 默认值 是否必须
    workflow_name string 工作流名称 无 must
    env_name string 集成环境名称 无 must
    targets []TargetArgs 构建参数 无 option
    release_images []Image 分发镜像信息 无 option
    callback Callback 工作流执行完成回调信息 无 option

    targets 和 release_images 必须有一个参数存在

    TargetArgs 参数说明
    参数名 类型 描述 默认值 是否必须
    name string 服务名称 无 must
    service_type string 服务部署方式,支持 k8s 或 helm k8s optional
    build BuildArgs 构建参数 无 must
    BuildArgs 参数说明
    参数名 类型 描述 默认值 是否必须
    repos []Repository 关联代码库信息 无 must
    Repository 参数说明
    参数名 类型 描述 默认值 是否必须
    repo_name string 代码库名称 无 must
    branch string 分支 无 must
    pr int pr ID 0 使用 pr 构建时必传
    Image 参数说明
    参数名 类型 描述 默认值 是否必须
    image string 镜像信息 无 must
    service_name string 服务名称 无 must
    service_module string 服务组件 无 must
    Callback 参数说明
    参数名 类型 描述 默认值 是否必须
    callback_url string 回调地址 无 must
    callback_vars map[string]Any 回调参数 无 optional

    # 正常返回

    {
      "project_name": "test-project",
      "workflow_name": "test-project-workflow-dev",
      "task_id": 74
    }
    
    1
    2
    3
    4
    5

    # 异常返回

    {
      "code": 6540,
      "description": "workflow [hello-world-workflow-dev] 在项目 [hellow-world] 中已经存在!",
      "extra": {},
      "message": "新建或更新wokflow失败",
      "type": "error"
    }
    
    1
    2
    3
    4
    5
    6
    7

    # 获取工作流任务详情

    # 请求

    GET /api/directory/workflowTask/id/:id/pipelines/:pipelineName
    
    1

    # 路径参数说明

    参数名 类型 描述 默认值 是否必须
    id int 任务 id 无 是
    pipelineName string 工作流名称 无 是

    # 正常返回

    {
        "workflow_name": "test-project-workflow-dev",
        "env_name": "dev",
        "targets": [
            {
                "name": "gss-1",
                "service_type": "helm",
                "build": {
                    "repos": [
                        {
                            "repo_name": "hzx-test",
                            "branch": "main",
                            "pr": 0
                        }
                    ]
                }
            },
            {
                "name": "gss-2",
                "service_type": "helm",
                "build": {
                    "repos": [
                        {
                            "repo_name": "hzx-test",
                            "branch": "main",
                            "pr": 0
                        }
                    ]
                }
            }
        ],
        "images": [
            {                    
                    "image": "ccr.ccs.tencentyun.com/trial/go-sample-site:20211221120415-1-main",
                    "service_name": "gss-1",
                    "registry_repo" : "https://ccr.ccs.tencentyun.com/trial"                    
            },
            {                    
                    "image": "ccr.ccs.tencentyun.com/trial/go-sample-site:20211221120415-1-main",
                    "service_name": "gss-2",
                    "registry_repo" : "https://ccr.ccs.tencentyun.com/trial"                    
            }
        ],
        "test_reports": [
            {
                "test_name": "test",
                "function_test_report": {
                    "tests": 24,
                    "successes": 24,
                    "failures": 0,
                    "skips": 0,
                    "errors": 0,
                    "detail_url": "/v1/projects/detail/test-project/pipelines/multi/testcase/test-project-workflow-dev/51/test/test-project-workflow-dev-51-test?is_workflow=1&service_name=test&test_type=function"
                }
            }
       ],
        "status": "timeout"
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58

    # 返回说明

    参数名 类型 描述
    workflow_name string 工作流名称
    env_name string 环境名称
    status string 任务状态
    targets []TargetArgs 构建参数
    images []Image 构建生成的镜像信息
    test_reports []TestReport 测试报告信息
    Image 参数说明
    参数名 类型 描述
    image string 镜像地址
    service_name string 服务名称
    registry_repo string 镜像仓库
    TestReport 参数说明
    参数名 类型 描述
    test_name string 测试名称
    function_test_report FunctionTestReport 测试报告概览
    FunctionTestReport 参数说明
    参数名 类型 描述
    tests int 测试用例数量
    successes int 成功数量
    failures int 失败数量
    skips int 跳过数量
    errors int 错误数量
    detail_url string 测试报告详情 URL

    # 异常返回

    {
        "code": 500,
        "description": "[400 BadRequest] {\"code\":6161,\"description\":\"\",\"extra\":{},\"message\":\"获取工作流任务失败\",\"type\":\"error\"}",
        "message": "Internal Error: "
    }
    
    1
    2
    3
    4
    5

    ← 交付中心 产品使用 FAQ→

    资源
    文档
    博客
    公司
    关于我们
    加入我们
    联系我们
    微信扫一扫
    hello@koderover.com
    上海市浦东软件园

    © 2022 筑栈(上海)信息技术有限公司 沪 ICP 备 19000177 号 - 1

    •  跟随系统
    •  浅色模式
    •  深色模式
    •  阅读模式