# Batch V1 API - Class Google::Cloud::Batch::V1::TaskSpec (v1.7.0)

1.7.0 (latest) 1.6.0 1.5.0 1.4.1 1.3.0 1.2.0 1.1.1 1.0.0 0.21.0 0.20.1 0.19.2 0.18.3 0.17.4 0.16.2 0.15.1 0.14.0 0.13.1 0.12.0 0.11.1 0.10.5 0.9.0 0.8.0 0.7.0 0.6.0 0.5.0 0.4.3 0.3.0 0.2.0 0.1.0 Reference documentation and code samples for the Batch V1 API class Google::Cloud::Batch::V1::TaskSpec.

Spec of a task

## Inherits

- Object

## Extended By

- Google::Protobuf::MessageExts::ClassMethods

## Includes

- Google::Protobuf::MessageExts

## Methods

### #compute_resource

    def compute_resource() -> ::Google::Cloud::Batch::V1::ComputeResource

**Returns**

- ([::Google::Cloud::Batch::V1::ComputeResource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-ComputeResource)) --- ComputeResource requirements.

### #compute_resource=

    def compute_resource=(value) -> ::Google::Cloud::Batch::V1::ComputeResource

**Parameter**

- **value** ([::Google::Cloud::Batch::V1::ComputeResource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-ComputeResource)) --- ComputeResource requirements.
**Returns**

- ([::Google::Cloud::Batch::V1::ComputeResource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-ComputeResource)) --- ComputeResource requirements.

### #environment

    def environment() -> ::Google::Cloud::Batch::V1::Environment

**Returns**

- ([::Google::Cloud::Batch::V1::Environment](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-Environment)) --- Environment variables to set before running the Task.

### #environment=

    def environment=(value) -> ::Google::Cloud::Batch::V1::Environment

**Parameter**

- **value** ([::Google::Cloud::Batch::V1::Environment](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-Environment)) --- Environment variables to set before running the Task.
**Returns**

- ([::Google::Cloud::Batch::V1::Environment](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-Environment)) --- Environment variables to set before running the Task.

### #environments

    def environments() -> ::Google::Protobuf::Map{::String => ::String}

**Returns**

- (::Google::Protobuf::Map{::String =\> ::String}) --- Deprecated: please use environment(non-plural) instead.

### #environments=

    def environments=(value) -> ::Google::Protobuf::Map{::String => ::String}

**Parameter**

- **value** (::Google::Protobuf::Map{::String =\> ::String}) --- Deprecated: please use environment(non-plural) instead.
**Returns**

- (::Google::Protobuf::Map{::String =\> ::String}) --- Deprecated: please use environment(non-plural) instead.

### #lifecycle_policies

    def lifecycle_policies() -> ::Array<::Google::Cloud::Batch::V1::LifecyclePolicy>

**Returns**

- (::Array\<[::Google::Cloud::Batch::V1::LifecyclePolicy](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-LifecyclePolicy)\>) --- Lifecycle management schema when any task in a task group is failed. Currently we only support one lifecycle policy. When the lifecycle policy condition is met, the action in the policy will execute. If task execution result does not meet with the defined lifecycle policy, we consider it as the default policy. Default policy means if the exit code is 0, exit task. If task ends with non-zero exit code, retry the task with max_retry_count.

### #lifecycle_policies=

    def lifecycle_policies=(value) -> ::Array<::Google::Cloud::Batch::V1::LifecyclePolicy>

**Parameter**

- **value** (::Array\<[::Google::Cloud::Batch::V1::LifecyclePolicy](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-LifecyclePolicy)\>) --- Lifecycle management schema when any task in a task group is failed. Currently we only support one lifecycle policy. When the lifecycle policy condition is met, the action in the policy will execute. If task execution result does not meet with the defined lifecycle policy, we consider it as the default policy. Default policy means if the exit code is 0, exit task. If task ends with non-zero exit code, retry the task with max_retry_count.
**Returns**

- (::Array\<[::Google::Cloud::Batch::V1::LifecyclePolicy](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-LifecyclePolicy)\>) --- Lifecycle management schema when any task in a task group is failed. Currently we only support one lifecycle policy. When the lifecycle policy condition is met, the action in the policy will execute. If task execution result does not meet with the defined lifecycle policy, we consider it as the default policy. Default policy means if the exit code is 0, exit task. If task ends with non-zero exit code, retry the task with max_retry_count.

### #max_retry_count

    def max_retry_count() -> ::Integer

**Returns**

- (::Integer) --- Maximum number of retries on failures. The default, 0, which means never retry. The valid value range is \[0, 10\].

### #max_retry_count=

    def max_retry_count=(value) -> ::Integer

**Parameter**

- **value** (::Integer) --- Maximum number of retries on failures. The default, 0, which means never retry. The valid value range is \[0, 10\].
**Returns**

- (::Integer) --- Maximum number of retries on failures. The default, 0, which means never retry. The valid value range is \[0, 10\].

### #max_run_duration

    def max_run_duration() -> ::Google::Protobuf::Duration

**Returns**

- ([::Google::Protobuf::Duration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Protobuf-Duration)) --- Maximum duration the task should run before being automatically retried (if enabled) or automatically failed. Format the value of this field as a time limit in seconds followed by `s`---for example, `3600s` for 1 hour. The field accepts any value between 0 and the maximum listed for the `Duration` field type at https://protobuf.dev/reference/protobuf/google.protobuf/#duration; however, the actual maximum run time for a job will be limited to the maximum run time for a job listed at https://cloud.google.com/batch/quotas#max-job-duration.

### #max_run_duration=

    def max_run_duration=(value) -> ::Google::Protobuf::Duration

**Parameter**

- **value** ([::Google::Protobuf::Duration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Protobuf-Duration)) --- Maximum duration the task should run before being automatically retried (if enabled) or automatically failed. Format the value of this field as a time limit in seconds followed by `s`---for example, `3600s` for 1 hour. The field accepts any value between 0 and the maximum listed for the `Duration` field type at https://protobuf.dev/reference/protobuf/google.protobuf/#duration; however, the actual maximum run time for a job will be limited to the maximum run time for a job listed at https://cloud.google.com/batch/quotas#max-job-duration.
**Returns**

- ([::Google::Protobuf::Duration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Protobuf-Duration)) --- Maximum duration the task should run before being automatically retried (if enabled) or automatically failed. Format the value of this field as a time limit in seconds followed by `s`---for example, `3600s` for 1 hour. The field accepts any value between 0 and the maximum listed for the `Duration` field type at https://protobuf.dev/reference/protobuf/google.protobuf/#duration; however, the actual maximum run time for a job will be limited to the maximum run time for a job listed at https://cloud.google.com/batch/quotas#max-job-duration.

### #runnables

    def runnables() -> ::Array<::Google::Cloud::Batch::V1::Runnable>

**Returns**

- (::Array\<[::Google::Cloud::Batch::V1::Runnable](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-Runnable)\>) ---

  Required. The sequence of one or more runnables (executable scripts,
  executable containers, and/or barriers) for each task in this task group to
  run. Each task runs this list of runnables in order. For a task to succeed,
  all of its script and container runnables each must meet at least one of
  the following conditions:
  - The runnable exited with a zero status.
  - The runnable didn't finish, but you enabled its `background` subfield.
  - The runnable exited with a non-zero status, but you enabled its `ignore_exit_status` subfield.

### #runnables=

    def runnables=(value) -> ::Array<::Google::Cloud::Batch::V1::Runnable>

**Parameter**

- **value** (::Array\<[::Google::Cloud::Batch::V1::Runnable](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-Runnable)\>) ---

  Required. The sequence of one or more runnables (executable scripts,
  executable containers, and/or barriers) for each task in this task group to
  run. Each task runs this list of runnables in order. For a task to succeed,
  all of its script and container runnables each must meet at least one of
  the following conditions:
  - The runnable exited with a zero status.
  - The runnable didn't finish, but you enabled its `background` subfield.
  - The runnable exited with a non-zero status, but you enabled its `ignore_exit_status` subfield.
**Returns**

- (::Array\<[::Google::Cloud::Batch::V1::Runnable](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-Runnable)\>) ---

  Required. The sequence of one or more runnables (executable scripts,
  executable containers, and/or barriers) for each task in this task group to
  run. Each task runs this list of runnables in order. For a task to succeed,
  all of its script and container runnables each must meet at least one of
  the following conditions:
  - The runnable exited with a zero status.
  - The runnable didn't finish, but you enabled its `background` subfield.
  - The runnable exited with a non-zero status, but you enabled its `ignore_exit_status` subfield.

### #volumes

    def volumes() -> ::Array<::Google::Cloud::Batch::V1::Volume>

**Returns**

- (::Array\<[::Google::Cloud::Batch::V1::Volume](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-Volume)\>) --- Volumes to mount before running Tasks using this TaskSpec.

### #volumes=

    def volumes=(value) -> ::Array<::Google::Cloud::Batch::V1::Volume>

**Parameter**

- **value** (::Array\<[::Google::Cloud::Batch::V1::Volume](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-Volume)\>) --- Volumes to mount before running Tasks using this TaskSpec.
**Returns**

- (::Array\<[::Google::Cloud::Batch::V1::Volume](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-Volume)\>) --- Volumes to mount before running Tasks using this TaskSpec.