> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/open-source/use-harness-open-source/pipelines-1/samples/task.md).

# Task

This guide covers configuring continuous integration pipelines to use [Task](https://taskfile.dev/).

## Example Task file <a href="#example-task-file" id="example-task-file"></a>

Here is an example `Taskfile.yml`.

```yaml
version: '3'

tasks:

  first:
    cmds:
      - echo "this is the {{.TASK}} task"

  second:
    deps: [first]
    cmds:
      - echo "this is the {{.TASK}} task"

  third:
    cmds:
      - echo "this is the {{.TASK}} task"
```

{% hint style="info" %}
The below examples assume this file is checked in to the root of your repository.
{% endhint %}

## Pipeline with one step <a href="#pipeline-with-one-step" id="pipeline-with-one-step"></a>

You can [install](https://taskfile.dev/installation/) Task and run `task` commands in a step.

```yaml
kind: pipeline
spec:
  stages:
    - name: task example
      type: ci
      spec:
        steps:
          - name: run tasks
            type: run
            spec:
              container: node:20
              script: |
                npm install -g @go-task/cli
                task second
                task third
```

## Pipeline with multiple steps <a href="#pipeline-with-multiple-steps" id="pipeline-with-multiple-steps"></a>

If your pipeline has multiple steps, each step that runs tasks will need the `task` binary.

Here is a pipeline that installs the task binary to `./bin` in the workspace, then runs tasks in separate steps.

```yaml
kind: pipeline
spec:
  stages:
    - name: task example
      type: ci
      spec:
        steps:
          - name: install task
            type: run
            spec:
              container: alpine
              script: |
                apk add curl
                sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d
                ./bin/task --version

          - name: second task
            type: run
            spec:
              container: alpine
              script: |
                ./bin/task second

          - name: third task
            type: run
            spec:
              container: alpine
              script: |
                ./bin/task third
```

## Temporary volume <a href="#temporary-volume" id="temporary-volume"></a>

If you don't want to install the `task` binary in the workspace, you can install it in a temporary volume.

```yaml
kind: pipeline
spec:
  stages:
    - name: task example
      type: ci
      spec:
        volumes:
          - name: shared
            type: temp
            spec: {}
        steps:
          - name: install task
            type: run
            spec:
              mount:
                - name: shared
                  path: /shared
              container: alpine
              script: |
                apk add curl
                sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /shared

          - name: task version
            type: run
            spec:
              mount:
                - name: shared
                  path: /shared
              container: alpine
              script: |
                /shared/task --version
```
