A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/batch/docs/create-run-basic-job below:

Create and run a basic job | Batch

Skip to main content Create and run a basic job

Stay organized with collections Save and categorize content based on your preferences.

This document explains the basics for Batch job creation: how to create and run a job that is based on a script or container image and use predefined and custom variables. To learn more about creating and running jobs, see Job creation and execution overview.

Before you begin
  1. If you haven't used Batch before, review Get started with Batch and enable Batch by completing the prerequisites for projects and users.
  2. To get the permissions that you need to create a job, ask your administrator to grant you the following IAM roles:

    For more information about granting roles, see Manage access to projects, folders, and organizations.

    You might also be able to get the required permissions through custom roles or other predefined roles.

  3. Each time you create a job, make sure the job has a valid network configuration. For more information about the network configuration for a job, see Batch networking overview.
  4. Each time you create a job, make sure the job has a valid VM operating system (OS) environment. For more information about the VM OS environment for a job, see VM OS environment overview.
Create a basic job

For information about all the fields you can specify for a job, see the reference documentation for the projects.locations.jobs REST resource. To summarize, a job consists of an array of one or more tasks that all run one or more runnables, which are the executable script(s) and/or container(s) for your job. To cover the basics, this section explains how to create an example job with just one runnable, either a script or a container image:

The example job for both types of jobs contains a task group with an array of 4 tasks. Each task prints a message and its index to the standard output and Cloud Logging. The definition for this job specifies a parallelism of 2, which indicates that the job should run on 2 VMs to allow 2 tasks to run at a time.

Create a basic container job

You can select or create a container image to provide the code and dependencies for your job to run from any compute environment. For more information, see Working with container images and Running containers on VM instances.

You can create a basic container job using the Google Cloud console, gcloud CLI, Batch API, Go, Java, Node.js, Python, or C++.

Console

To create a basic container job using the Google Cloud console, do the following:

  1. In the Google Cloud console, go to the Job list page.

    Go to Job list

  2. Click add_box Create. The Create batch job page opens. In the left pane, the Job details page is selected.

  3. Configure the Job details page:

    1. Optional: In the Job name field, customize the job name.

      For example, enter example-basic-job.

    2. Configure the Task details section:

      1. In the New runnable window, add at least one script or container for this job to run.

        For example, to add one container, do the following:

        1. Select Container image URL (default).

        2. In the Container image URL field, enter the URL for a container image that you want to run for each task in this job.

          For example, to use the busybox Docker container image, enter the following URL:

          gcr.io/google-containers/busybox
          
        3. Optional: To override the container image's ENTRYPOINT command, enter a command in the Entry point field.

          For example, enter the following:

          /bin/sh
          
        4. Optional: To override the container image's CMD command, do the following:

          1. Select the Override container image's CMD command checkbox. A field appears.

          2. In the field, enter one or more commands, separating each command with a new line.

            For example, enter the following commands:

            -c
            echo Hello world! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks.
            
          3. Click Done.

      2. In the Task count field, enter the number of tasks for this job. The value must be a whole number between 1 and the tasks per task group limit.

        For example, enter 4.

      3. In the Parallelism field, enter the number of tasks to run concurrently. The number cannot be larger than the total number of tasks and must be a whole number between 1 and the parallel tasks per job limit.

        For example, enter 2.

  4. Configure the Resource specifications page:

    1. In the left pane, click Resource specifications. The Resource specifications page opens.

    2. In the VM provisioning model section, select one of the following options for the provisioning model for this job's VMs:

      • If your job can withstand preemption and you want discounted VMs, select Spot.

      • Otherwise, select Standard.

      For example, select Standard (default).

    3. Select the location for this job:

      1. In the Region field, select a region.

        For example, select us-central1 (Iowa) (default).

      2. In the Zone field, do one of the following:

        • If you want to restrict this job to run in a specific zone only, select a zone.

        • Otherwise, select any.

        For example, select any (default).

    4. Select one of the following machine families:

      • For common workloads, click General purpose.

      • For performance-intensive workloads, click Compute optimized.

      • For memory-intensive workloads, click Memory optimized.

      • For accelerator-optimized workloads, click GPUs. For more information, see Create and run a job that uses GPUs.

      For example, click General purpose (default).

    5. In the Series field, select a machine series for this job's VMs.

      For example, if you selected General purpose for the machine family, select E2 (default).

    6. In the Machine type field, select a machine type for this job's VMs.

      For example, if you selected E2 for the machine series, select e2-medium (2 vCPU, 4 GB memory) (default).

    7. Configure the amount of VM resources required for each task:

      1. In the Cores field, enter the amount of vCPUs per task.

        For example, enter 1 (default).

      2. In the Memory field, enter the amount of RAM in GB per task.

        For example, enter 0.5 (default).

  5. Optional: To review the job configuration, in the left pane, click Preview.

  6. Click Create.

The Job details page displays the job that you created.

gcloud

To create a basic container job using the gcloud CLI, do the following:

  1. Create a JSON file that specifies your job's configuration details. For example, to create a basic container job, create a JSON file with the following contents. For more information about all the fields you can specify for a job, see the reference documentation for the projects.locations.jobs REST resource.

    Note: If you prefer, you can specify your job's configuration details in a YAML file instead of a JSON file by converting JSON syntax to YAML syntax yourself. However, the Batch documentation only provides examples for JSON syntax. For more information, see the gcloud batch jobs submit command.
    {
        "taskGroups": [
            {
                "taskSpec": {
                    "runnables": [
                        {
                            "container": {
                                CONTAINER
                            }
                        }
                    ],
                    "computeResource": {
                        "cpuMilli": CORES,
                        "memoryMib": MEMORY
                    },
                    "maxRetryCount": MAX_RETRY_COUNT,
                    "maxRunDuration": "MAX_RUN_DURATION"
                },
                "taskCount": TASK_COUNT,
                "parallelism": PARALLELISM
            }
        ]
    }
    

    Replace the following:

  2. Create a job by using the gcloud batch jobs submit command.

    gcloud batch jobs submit JOB_NAME \
      --location LOCATION \
      --config JSON_CONFIGURATION_FILE
    

    Replace the following:

For example, to create a job that runs tasks using the busybox Docker container image:

  1. Create a JSON file in the current directory named hello-world-container.json with the following contents:

    {
        "taskGroups": [
            {
                "taskSpec": {
                    "runnables": [
                        {
                            "container": {
                                "imageUri": "gcr.io/google-containers/busybox",
                                "entrypoint": "/bin/sh",
                                "commands": [
                                    "-c",
                                    "echo Hello world! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks."
                                ]
                            }
                        }
                    ],
                    "computeResource": {
                        "cpuMilli": 2000,
                        "memoryMib": 16
                    },
                    "maxRetryCount": 2,
                    "maxRunDuration": "3600s"
                },
                "taskCount": 4,
                "parallelism": 2
            }
        ],
        "allocationPolicy": {
            "instances": [
                {
                    "policy": { "machineType": "e2-standard-4" }
                }
            ]
        },
        "labels": {
            "department": "finance",
            "env": "testing"
        },
        "logsPolicy": {
            "destination": "CLOUD_LOGGING"
        }
    }
    
  2. Run the following command:

    gcloud batch jobs submit example-container-job \
      --location us-central1 \
      --config hello-world-container.json
    
API

To create a basic container job using the Batch API, use the jobs.create method. For more information about all the fields you can specify for a job, see the reference documentation for the projects.locations.jobs REST resource.

POST https://batch.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobs?job_id=JOB_NAME

{
    "taskGroups": [
        {
            "taskSpec": {
                "runnables": [
                    {
                        "container": {
                            CONTAINER
                        }
                    }
                ],
                "computeResource": {
                    "cpuMilli": CORES,
                    "memoryMib": MEMORY
                },
                "maxRetryCount": MAX_RETRY_COUNT,
                "maxRunDuration": "MAX_RUN_DURATION"
            },
            "taskCount": TASK_COUNT,
            "parallelism": PARALLELISM
        }
    ]
}

Replace the following:

For example, to create a job that runs tasks using the busybox Docker container image, use the following request:

POST https://batch.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/jobs?job_id=example-container-job

{
    "taskGroups": [
        {
            "taskSpec": {
                "runnables": [
                    {
                        "container": {
                            "imageUri": "gcr.io/google-containers/busybox",
                            "entrypoint": "/bin/sh",
                            "commands": [
                                "-c",
                                "echo Hello world! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks."
                            ]
                        }
                    }
                ],
                "computeResource": {
                    "cpuMilli": 2000,
                    "memoryMib": 16
                },
                "maxRetryCount": 2,
                "maxRunDuration": "3600s"
            },
            "taskCount": 4,
            "parallelism": 2
        }
    ],
    "allocationPolicy": {
        "instances": [
            {
                "policy": { "machineType": "e2-standard-4" }
            }
        ]
    },
    "labels": {
        "department": "finance",
        "env": "testing"
    },
    "logsPolicy": {
        "destination": "CLOUD_LOGGING"
    }
}

where PROJECT_ID is the project ID of your project.

Go Go

For more information, see the Batch Go API reference documentation.

To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Java Java

For more information, see the Batch Java API reference documentation.

To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Node.js Node.js

For more information, see the Batch Node.js API reference documentation.

To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Python Python

For more information, see the Batch Python API reference documentation.

To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

C++ C++

For more information, see the Batch C++ API reference documentation.

To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Create a basic script job

You can create a basic script job using the Google Cloud console, gcloud CLI, Batch API, Go, Java, Node.js, Python, or C++.

Console

To create a basic script job using the Google Cloud console, do the following:

  1. In the Google Cloud console, go to the Job list page.

    Go to Job list

  2. Click add_box Create. The Create batch job page opens. In the left pane, the Job details page is selected.

  3. Configure the Job details page:

    1. Optional: In the Job name field, customize the job name.

      For example, enter example-basic-job.

    2. Configure the Task details section:

      1. In the New runnable window, add at least one script or container for this job to run.

        For example, to add one script, do the following:

        1. Select Script. A field appears.

        2. In the field, enter a script that you want to run for each task in this job.

          For example, enter the following script:

          echo Hello world! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks.
          
        3. Click Done.

      2. In the Task count field, enter the number of tasks for this job. The value must be a whole number between 1 and the tasks per task group limit.

        For example, enter 4.

      3. In the Parallelism field, enter the number of tasks to run concurrently. The number cannot be larger than the total number of tasks and must be a whole number between 1 and the parallel tasks per job limit.

        For example, enter 2.

  4. Configure the Resource specifications page:

    1. In the left pane, click Resource specifications. The Resource specifications page opens.

    2. In the VM provisioning model section, select one of the following options for the provisioning model for this job's VMs:

      • If your job can withstand preemption and you want discounted VMs, select Spot.

      • Otherwise, select Standard.

      For example, select Standard (default).

    3. Select the location for this job:

      1. In the Region field, select a region.

        For example, select us-central1 (Iowa) (default).

      2. In the Zone field, do one of the following:

        • If you want to restrict this job to run in a specific zone only, select a zone.

        • Otherwise, select any.

        For example, select any (default).

    4. Select one of the following machine families:

      • For common workloads, click General purpose.

      • For performance-intensive workloads, click Compute optimized.

      • For memory-intensive workloads, click Memory optimized.

      • For accelerator-optimized workloads, click GPUs. For more information, see Create and run a job that uses GPUs.

      For example, click General purpose (default).

    5. In the Series field, select a machine series for this job's VMs.

      For example, if you selected General purpose for the machine family, select E2 (default).

    6. In the Machine type field, select a machine type for this job's VMs.

      For example, if you selected E2 for the machine series, select e2-medium (2 vCPU, 4 GB memory) (default).

    7. Configure the amount of VM resources required for each task:

      1. In the Cores field, enter the amount of vCPUs per task.

        For example, enter 1 (default).

      2. In the Memory field, enter the amount of RAM in GB per task.

        For example, enter 0.5 (default).

  5. Optional: To review the job configuration, in the left pane, click Preview.

  6. Click Create.

    The Job details page displays the job that you created.

gcloud

To create a basic script job using the gcloud CLI, do the following:

  1. Create a JSON file that specifies your job's configuration details. For example, to create a basic script job, create a JSON file with the following contents. For more information about all the fields you can specify for a job, see the reference documentation for the projects.locations.jobs REST resource.

    Note: If you prefer, you can specify your job's configuration details in a YAML file instead of a JSON file by converting JSON syntax to YAML syntax yourself. However, the Batch documentation only provides examples for JSON syntax. For more information, see the gcloud batch jobs submit command.
    {
        "taskGroups": [
            {
                "taskSpec": {
                    "runnables": [
                        {
                            "script": {
                                SCRIPT
                            }
                        }
                    ],
                    "computeResource": {
                        "cpuMilli": CORES,
                        "memoryMib": MEMORY
                    },
                    "maxRetryCount": MAX_RETRY_COUNT,
                    "maxRunDuration": "MAX_RUN_DURATION"
                },
                "taskCount": TASK_COUNT,
                "parallelism": PARALLELISM
            }
        ]
    }
    

    Replace the following:

  2. Create a job by using the gcloud batch jobs submit command.

    gcloud batch jobs submit JOB_NAME \
      --location LOCATION \
      --config JSON_CONFIGURATION_FILE
    

    Replace the following:

For example, to create a job that runs tasks using a script:

  1. Create a JSON file in the current directory named hello-world-script.json with the following contents:

    {
        "taskGroups": [
            {
                "taskSpec": {
                    "runnables": [
                        {
                            "script": {
                                "text": "echo Hello world! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks."
                            }
                        }
                    ],
                    "computeResource": {
                        "cpuMilli": 2000,
                        "memoryMib": 16
                    },
                    "maxRetryCount": 2,
                    "maxRunDuration": "3600s"
                },
                "taskCount": 4,
                "parallelism": 2
            }
        ],
        "allocationPolicy": {
            "instances": [
                {
                    "policy": { "machineType": "e2-standard-4" }
                }
            ]
        },
        "labels": {
            "department": "finance",
            "env": "testing"
        },
        "logsPolicy": {
            "destination": "CLOUD_LOGGING"
        }
    }
    
  2. Run the following command:

    gcloud batch jobs submit example-script-job \
      --location us-central1 \
      --config hello-world-script.json
    
API

To create a basic script job using the Batch API, use the jobs.create method. For more information about all the fields you can specify for a job, see the reference documentation for the projects.locations.jobs REST resource.

POST https://batch.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobs?job_id=JOB_NAME

{
    "taskGroups": [
        {
            "taskSpec": {
                "runnables": [
                    {
                        "script": {
                            SCRIPT
                        }
                    }
                ],
                "computeResource": {
                    "cpuMilli": CORES,
                    "memoryMib": MEMORY
                },
                "maxRetryCount": MAX_RETRY_COUNT,
                "maxRunDuration": "MAX_RUN_DURATION"
            },
            "taskCount": TASK_COUNT,
            "parallelism": PARALLELISM
        }
    ]
}

Replace the following:

For example, to create a job that runs tasks using a script, use the following request:

POST https://batch.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/jobs?job_id=example-script-job

{
    "taskGroups": [
        {
            "taskSpec": {
                "runnables": [
                    {
                        "script": {
                            "text": "echo Hello world! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks."
                        }
                    }
                ],
                "computeResource": {
                    "cpuMilli": 2000,
                    "memoryMib": 16
                },
                "maxRetryCount": 2,
                "maxRunDuration": "3600s"
            },
            "taskCount": 4,
            "parallelism": 2
        }
    ],
    "allocationPolicy": {
        "instances": [
            {
                "policy": { "machineType": "e2-standard-4" }
            }
        ]
    },
    "labels": {
        "department": "finance",
        "env": "testing"
    },
    "logsPolicy": {
        "destination": "CLOUD_LOGGING"
    }
}

where PROJECT_ID is the project ID of your project.

Go Go

For more information, see the Batch Go API reference documentation.

To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Java Java

For more information, see the Batch Java API reference documentation.

To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Node.js Node.js

For more information, see the Batch Node.js API reference documentation.

To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Python Python

For more information, see the Batch Python API reference documentation.

To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

C++ C++

For more information, see the Batch C++ API reference documentation.

To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Use environment variables

Use environment variables when you write a container image or script that you want a job to run. You can use any of the environment variables that are predefined for all Batch jobs and any custom environment variables that you define while creating the job.

Use predefined environment variables

By default, the runnables in your job can use the following predefined environment variables:

For an example of how to use predefined environment variables, see the previous example runnables in Create a basic job in this document.

Define and use custom environment variables

Optionally, you can define one or more custom environment variables in a job.

You define each variable in a specific environment based on the desired scope of its data:

In the selected environment, you define the name and value(s) of each variable by using one of the following environment subfields:

You can define and use custom environment variables for your job using the gcloud CLI or Batch API. The following examples explain how to create two jobs that define and use standard variables. The first example job has a variable for a specific runnable. The second example job has an array variable, which has a different value for each task.

gcloud

If you want to define a job that passes an environment variable to a runnable that each task runs, see the example for how to Define and use an environment variable for a runnable. Otherwise, if you want to define a job that passes a list of environment variables to different tasks based on the task index, see the example for how to Define and use an environment variable for each task.

Define and use an environment variable for a runnable

To create a job that passes environment variables to a runnable using the gcloud CLI, use the gcloud batch jobs submit command and specify the environment variables in the job's configuration file.

For example, to create a script job that defines an environment variable and passes it to the scripts of 3 tasks, make the following request:

  1. Create a JSON file in the current directory named hello-world-environment-variables.json with the following contents:

    {
        "taskGroups": [
            {
                "taskSpec": {
                    "runnables": [
                        {
                            "script": {
                                "text": "echo Hello ${VARIABLE_NAME}! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks."
                            },
                            "environment": {
                                "variables": {
                                    "VARIABLE_NAME": "VARIABLE_VALUE"
                                }
                            }
                        }
                    ],
                    "computeResource": {
                        "cpuMilli": 2000,
                        "memoryMib": 16
                    }
                },
                "taskCount": 3,
                "parallelism": 1
            }
        ],
        "allocationPolicy": {
            "instances": [
                {
                    "policy": {
                        "machineType": "e2-standard-4"
                    }
                }
            ]
        }
    }
    

    Replace the following:

  2. Run the following command:

    gcloud batch jobs submit example-environment-variables-job \
      --location us-central1 \
      --config hello-world-environment-variables.json
    
Define and use an environment variable for each task

To create a job that passes environment variables to a task based on task index using the gcloud CLI, use the gcloud batch jobs submit command and specify the taskEnvironments array field in the job's configuration file.

For example, to create a job that includes an array of 3 environment variables with matching names and different values, and passes the environment variables to the scripts of the tasks which indices match the environment variables' indices in the array:

  1. Create a JSON file in the current directory named hello-world-task-environment-variables.json with the following contents:

    {
        "taskGroups": [
            {
                "taskSpec": {
                    "runnables": [
                        {
                            "script": {
                                "text": "echo Hello ${TASK_VARIABLE_NAME}! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks."
                            },
                        }
                    ],
                    "computeResource": {
                        "cpuMilli": 2000,
                        "memoryMib": 16
                    }
                },
                "taskCount": 3,
                "taskEnvironments": [
                    {
                        "variables": {
                            "TASK_VARIABLE_NAME": "TASK_VARIABLE_VALUE_0"
                        }
                    },
                    {
                        "variables": {
                            "TASK_VARIABLE_NAME": "TASK_VARIABLE_VALUE_1"
                        }
                    },
                    {
                        "variables": {
                            "TASK_VARIABLE_NAME": "TASK_VARIABLE_VALUE_2"
                        }
                    }
                ]
            }
        ],
        "allocationPolicy": {
            "instances": [
                {
                    "policy": {
                        "machineType": "e2-standard-4"
                    }
                }
            ]
        }
    }
    

    Replace the following:

    Note: If an environment variable is specified in the taskEnvironments array field, the value of the taskCount field must then equal the length of the taskEnvironments array. The maximum length of the taskEnvironments array is 200.
  2. Run the following command:

    gcloud batch jobs submit example-task-environment-variables-job \
      --location us-central1 \
      --config hello-world-task-environment-variables.json
    
API

If you want to define a job that passes an environment variable to a runnable that each task runs, see the example for how to Define and use an environment variable for a runnable. Otherwise, if you want to define a job that passes a list of environment variables to different tasks based on the task index, see the example for how to Define and use an environment variable for each task.

Define and use an environment variable for a runnable

To create a job that passes environment variables to a runnable using Batch API, use the gcloud batch jobs submit command and specify the environment variables in the environment field.

For example, to create a job that includes an environment variable and passes it to the scripts of 3 tasks, make the following request:

POST https://batch.googleapis.com/v1/projects/<var>PROJECT_ID</var>/locations/us-central1/jobs?job_id=example-environment-variables-job

{
    "taskGroups": [
        {
            "taskSpec": {
                "runnables": [
                    {
                        "script": {
                            "text": "echo Hello ${VARIABLE_NAME}! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks."
                        },
                        "environment": {
                            "variables": {
                                "VARIABLE_NAME": "VARIABLE_VALUE"
                            }
                        }
                    }
                ],
                "computeResource": {
                    "cpuMilli": 2000,
                    "memoryMib": 16
                }
            },
            "taskCount": 3,
            "parallelism": 1
        }

    ],
    "allocationPolicy": {
        "instances": [
            {
                "policy": {
                    "machineType": "e2-standard-4"
                }
            }
        ]
    }
}

Replace the following:

Define and use an environment variable for each task

To create a job that passes environment variables to a task based on task index using Batch API, use the jobs.create method and specify the environment variables in the taskEnvironments array field.

For example, to create a job that includes an array of 3 environment variables with matching names and different values, and passes the environment variables to the scripts of 3 tasks based on their indices, make the following request:

POST https://batch.googleapis.com/v1/projects/<var>PROJECT_ID</var>/locations/us-central1/jobs?job_id=example-task-environment-variables-job

{
    "taskGroups": [
        {
            "taskSpec": {
                "runnables": [
                    {
                        "script": {
                            "text": "echo Hello ${TASK_VARIABLE_NAME}! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks."
                        },
                    }
                ],
                "computeResource": {
                    "cpuMilli": 2000,
                    "memoryMib": 16
                }
            },
            "taskCount": 3,
            "taskEnvironments": [
                {
                    "variables": {
                        "TASK_VARIABLE_NAME": "TASK_VARIABLE_VALUE_0"
                    }
                },
                {
                    "variables": {
                        "TASK_VARIABLE_NAME": "TASK_VARIABLE_VALUE_1"
                    }
                },
                {
                    "variables": {
                        "TASK_VARIABLE_NAME": "TASK_VARIABLE_VALUE_2"
                    }
                }
            ]
        }
    ],
    "allocationPolicy": {
        "instances": [
            {
                "policy": { "machineType": "e2-standard-4" }
            }
        ]
    }
}

Replace the following:

Note: If an environment variable is specified in the taskEnvironments array field, the taskCount field's value must then equal the length of the taskEnvironments array. The maximum length of the taskEnvironments array is 200. What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Batch jobs are composed of task groups, each containing tasks that execute either scripts or container images."],["You can create batch jobs via the console, `gcloud` CLI, or API, with options to configure details like task count, parallelism, VM provisioning, and resource specifications."],["Predefined environment variables such as `BATCH_TASK_COUNT`, `BATCH_TASK_INDEX`, and `BATCH_TASK_RETRY_ATTEMPT` are automatically available to tasks, with `BATCH_HOSTS_FILE` being optional."],["Custom variables can be set for all tasks or specific runnables, or even have different values for each task, using the `variables`, `secretVariables`, or `encryptedVariables` subfields in the job configuration."],["Using gcloud or the API you can define either runnable variables or task-specific variables."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4