# CodePipelinePhaseDefinition

A phase of a code pipeline: a group of steps that runs once the phases it depends on have finished.

**Kind:** an object, used in requests and responses. In a request it is called `CodePipelinePhaseDefinitionInput`.

## In a request

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | `string` |  | The phase's name, unique within the pipeline. |
| `dependsOn` | `string[] \| null` |  | The phases that must all finish successfully before this one starts. Null or empty: it can start straight away. |
| `steps` | [`CodePipelineStepDefinitionInput`](https://docs.maitento.com/reference/types/code-pipeline-step-definition.md#in-a-request)`[]` |  | The phase's steps. One agent's steps run one after another, in order; different agents' steps run in parallel unless a step's `dependsOn` says otherwise. |
| `preHook` | `string \| null` |  | The name of a hook (a Cogniscript method in the pipeline's hooks) to run before the phase's steps. |
| `postHook` | `string \| null` |  | The name of a hook to run after all the phase's steps finish. Often used to read step outputs and add phases or steps. |
| `onFailHook` | `string \| null` |  | The name of a hook to run when the phase fails. It returns JSON with a `decision`: `"continue"` marks the phase skipped and carries on, `"fail"` fails the run as usual. |
| `durationWarning` | `timespan \| null` |  | Not used by code pipeline runs. |
| `durationAutoTermination` | `timespan \| null` |  | The longest any step in this phase may run, for steps that set no `durationAutoTermination` of their own. Null: the pipeline's value applies. |
| `durationActivityTimeout` | `timespan \| null` |  | How long any step in this phase may go without activity before it is stopped, for steps that set no `durationActivityTimeout` of their own. Null: the pipeline's value applies. |

```json
{
  "name": "...",
  "dependsOn": [
    "..."
  ],
  "steps": [
    {
      "name": "...",
      "agentName": "...",
      "targetRole": "Architect",
      "targetTags": [],
      "prompt": "...",
      "dependsOn": [],
      "isCommitable": false,
      "commitRepoName": "...",
      "isStructuredOutput": false,
      "outputJsonSchema": "...",
      "isOutputSchemaRequired": false,
      "outputVariableName": "...",
      "outputFileName": "...",
      "preHook": "...",
      "postHook": "...",
      "onFailHook": "...",
      "isNewSession": false,
      "runChallengeLoop": false,
      "durationWarning": "00:05:00",
      "durationAutoTermination": "00:05:00",
      "durationActivityTimeout": "00:05:00"
    }
  ],
  "preHook": "...",
  "postHook": "...",
  "onFailHook": "...",
  "durationWarning": "00:05:00",
  "durationAutoTermination": "00:05:00",
  "durationActivityTimeout": "00:05:00"
}
```

## In a response

Every field is present in a response; empty ones are `null`.

| Field | Type | Description |
|---|---|---|
| `name` | `string` | The phase's name, unique within the pipeline. |
| `dependsOn` | `string[] \| null` | The phases that must all finish successfully before this one starts. Null or empty: it can start straight away. |
| `steps` | [`CodePipelineStepDefinition`](https://docs.maitento.com/reference/types/code-pipeline-step-definition.md)`[]` | The phase's steps. One agent's steps run one after another, in order; different agents' steps run in parallel unless a step's `dependsOn` says otherwise. |
| `preHook` | `string \| null` | The name of a hook (a Cogniscript method in the pipeline's hooks) to run before the phase's steps. |
| `postHook` | `string \| null` | The name of a hook to run after all the phase's steps finish. Often used to read step outputs and add phases or steps. |
| `onFailHook` | `string \| null` | The name of a hook to run when the phase fails. It returns JSON with a `decision`: `"continue"` marks the phase skipped and carries on, `"fail"` fails the run as usual. |
| `durationWarning` | `timespan \| null` | Not used by code pipeline runs. |
| `durationAutoTermination` | `timespan \| null` | The longest any step in this phase may run, for steps that set no `durationAutoTermination` of their own. Null: the pipeline's value applies. |
| `durationActivityTimeout` | `timespan \| null` | How long any step in this phase may go without activity before it is stopped, for steps that set no `durationActivityTimeout` of their own. Null: the pipeline's value applies. |

```json
{
  "name": "...",
  "dependsOn": [
    "..."
  ],
  "steps": [
    {
      "name": "...",
      "agentName": "...",
      "targetRole": "Architect",
      "targetTags": [],
      "prompt": "...",
      "dependsOn": [],
      "isCommitable": false,
      "commitRepoName": "...",
      "isStructuredOutput": false,
      "outputJsonSchema": "...",
      "isOutputSchemaRequired": false,
      "outputVariableName": "...",
      "outputFileName": "...",
      "preHook": "...",
      "postHook": "...",
      "onFailHook": "...",
      "isNewSession": false,
      "runChallengeLoop": false,
      "durationWarning": "00:05:00",
      "durationAutoTermination": "00:05:00",
      "durationActivityTimeout": "00:05:00"
    }
  ],
  "preHook": "...",
  "postHook": "...",
  "onFailHook": "...",
  "durationWarning": "00:05:00",
  "durationAutoTermination": "00:05:00",
  "durationActivityTimeout": "00:05:00"
}
```

## Where it's used

- Inside [`CodePipelineCreateRequest`](https://docs.maitento.com/reference/types/code-pipeline-create-request.md)
- Inside [`CodePipelineProcess`](https://docs.maitento.com/reference/types/code-pipeline-process.md)
- Inside [`CodePipelineUpdateRequest`](https://docs.maitento.com/reference/types/code-pipeline-update-request.md)
- Inside [`CodePipelineVersion`](https://docs.maitento.com/reference/types/code-pipeline-version.md)
