Batch 连接器

Workflows 连接器,用于定义用于在工作流中访问 Batch 的内置函数。

深入探索

如需查看包含此代码示例的详细文档,请参阅以下内容:

代码示例

YAML

# This workflow demonstrates how to use the Batch connector.
# This workflow sends a List request to Batch connector.
main:
  steps:
    - init:
        assign:
          - project: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
          - location: ${sys.get_env("GOOGLE_CLOUD_LOCATION")}
          - jobId: "example-job"
    - create_job:
        call: googleapis.batch.v1.projects.locations.jobs.create
        args:
          parent: ${"projects/" + project + "/locations/" + location}
          jobId: ${jobId}
          body:
            priority: 99
            taskGroups:
              taskSpec:
                runnables:
                  script:
                    text: "echo Hello World!"
                computeResource:
                  cpuMilli: 2000
                  memoryMib: 16
              taskCount: 1
    - delete_job:
        call: googleapis.batch.v1.projects.locations.jobs.delete
        args:
          name: ${"projects/" + project + "/locations/" + location + "/jobs/" + jobId}

后续步骤

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