适用于 Workflows 执行作业的连接器

定义用于访问 Workflows 执行作业的内置函数的 Workflows 连接器。

包含此代码示例的文档页面

如需查看代码示例的实际使用场景,请参阅以下文档:

代码示例

YAML

# This workflow demonstrates how to use the Cloud Workflow Executions connector
# to create an execution for a workflow. Make sure the workflow
# already exists in your project.
# Expected successful output: "SUCCESS"

- init:
    assign:
    - project: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
    - location: "us-central1"
    - workflow: "[fill in the workflow to execute]"  # Make sure this workflow exists in your project.
    - arguments:
        hello: world
        integer: 100
        boolean: true
# The run helper method is the preferred way to execute a workflow as it doesn't require
# encoding the workflow arguments in a JSON-formatted string. To compare
# the usage, we list two demo steps:
- run_execution:
    call: googleapis.workflowexecutions.v1.projects.locations.workflows.executions.run
    args:
      workflow_id: ${workflow}
      location: ${location}
      project_id: ${project}
      argument: ${arguments}  # Arguments could be specified inline as a map instead.
    result: r1
- create_execution:
    call: googleapis.workflowexecutions.v1.projects.locations.workflows.executions.create
    args:
      parent: ${"projects/" + project + "/locations/" + location + "/workflows/" + workflow}
      body:
        argument: ${json.encode_to_string(arguments)}
    result: r2
- the_end:
    return: [${r1}, ${r2}]

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器