public RepeatedField<LifecyclePolicy> LifecyclePolicies { get; }
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.
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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eTaskSpec\u003c/code\u003e class defines the specifications for a task within the Batch v1alpha API, serving as a blueprint for task execution.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eTaskSpec\u003c/code\u003e allows configuration of compute resources, environment variables, and a sequence of runnables (scripts, containers, barriers) that will be executed by each task.\u003c/p\u003e\n"],["\u003cp\u003eLifecycle policies and retry mechanisms can be configured through \u003ccode\u003eLifecyclePolicies\u003c/code\u003e and \u003ccode\u003eMaxRetryCount\u003c/code\u003e, allowing control over task execution based on failure or success conditions.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eMaxRunDuration\u003c/code\u003e property allows setting a time limit for task execution, after which the task will be retried or marked as failed.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eTaskSpec\u003c/code\u003e provides capabilities to define volumes to be mounted for the task, offering storage management options and environment control.\u003c/p\u003e\n"]]],[],null,["# Batch v1alpha API - Class TaskSpec (1.0.0-alpha31)\n\nVersion latestkeyboard_arrow_down\n\n- [1.0.0-alpha31 (latest)](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.TaskSpec)\n- [1.0.0-alpha30](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/1.0.0-alpha30/Google.Cloud.Batch.V1Alpha.TaskSpec) \n\n public sealed class TaskSpec : IMessage\u003cTaskSpec\u003e, IEquatable\u003cTaskSpec\u003e, IDeepCloneable\u003cTaskSpec\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Batch v1alpha API class TaskSpec.\n\nSpec of a task \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e TaskSpec \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[TaskSpec](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.TaskSpec), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[TaskSpec](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.TaskSpec), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[TaskSpec](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.TaskSpec), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Batch.V1Alpha](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha)\n\nAssembly\n--------\n\nGoogle.Cloud.Batch.V1Alpha.dll\n\nConstructors\n------------\n\n### TaskSpec()\n\n public TaskSpec()\n\n### TaskSpec(TaskSpec)\n\n public TaskSpec(TaskSpec other)\n\nProperties\n----------\n\n### ComputeResource\n\n public ComputeResource ComputeResource { get; set; }\n\nComputeResource requirements.\n\n### Environment\n\n public Environment Environment { get; set; }\n\nEnvironment variables to set before running the Task.\n\n### Environments\n\n [Obsolete]\n public MapField\u003cstring, string\u003e Environments { get; }\n\nDeprecated: please use environment(non-plural) instead.\n\n### LifecyclePolicies\n\n public RepeatedField\u003cLifecyclePolicy\u003e LifecyclePolicies { get; }\n\nLifecycle management schema when any task in a task group is failed.\nCurrently we only support one lifecycle policy.\nWhen the lifecycle policy condition is met,\nthe action in the policy will execute.\nIf task execution result does not meet with the defined lifecycle\npolicy, we consider it as the default policy.\nDefault policy means if the exit code is 0, exit task.\nIf task ends with non-zero exit code, retry the task with max_retry_count.\n\n### MaxRetryCount\n\n public int MaxRetryCount { get; set; }\n\nMaximum number of retries on failures.\nThe default, 0, which means never retry.\nThe valid value range is \\[0, 10\\].\n\n### MaxRunDuration\n\n public Duration MaxRunDuration { get; set; }\n\nMaximum duration the task should run before being automatically retried\n(if enabled) or automatically failed. Format the value of this field\nas a time limit in seconds followed by `s`\\—for example, `3600s`\nfor 1 hour. The field accepts any value between 0 and the maximum listed\nfor the `Duration` field type at\n\u003chttps://protobuf.dev/reference/protobuf/google.protobuf/#duration\u003e; however,\nthe actual maximum run time for a job will be limited to the maximum run\ntime for a job listed at\n\u003chttps://cloud.google.com/batch/quotas#max-job-duration\u003e.\n\n### Runnables\n\n public RepeatedField\u003cRunnable\u003e Runnables { get; }\n\nRequired. The sequence of one or more runnables (executable scripts,\nexecutable containers, and/or barriers) for each task in this task group to\nrun. Each task runs this list of runnables in order. For a task to succeed,\nall of its script and container runnables each must meet at least one of\nthe following conditions:\n\n- The runnable exited with a zero status.\n- The runnable didn't finish, but you enabled its `background` subfield.\n- The runnable exited with a non-zero status, but you enabled its `ignore_exit_status` subfield.\n\n### Volumes\n\n public RepeatedField\u003cVolume\u003e Volumes { get; }\n\nVolumes to mount before running Tasks using this TaskSpec."]]