Skip to content

Add retry feature #1540

Closed
Closed

Description

@birdayz

Make commands retryable:

...
tasks:
  build:
    retry:
      attempts: 3
      exit_codes:
        - 1
        - 127
    cmds:
     ...

If exit_codes is provided, only the provided exit codes are retryable. otherwise, all exit code are retried.

I have a use case, where a task runs many other tasks via deps. One of them fails, it all fails. In the end, CI retrys the entire task invocation, which will again run all of these parallel tasks. However, it would be much better to only retry the individual task that fails.
I can do the retry within the cmd, but that's not very elegant and re-usable i feel.

Activity

  1. danilobuerger commented on Jun 18, 2024

    @danilobuerger
    Contributor

    Best case, this should also include a delay.

  2. trulede commented on Feb 27, 2026

    @trulede
    Contributor

    The situation as you describe is resolved by using Task features such as 'sources', 'generates', and 'run'. Subsequent runs of Task will not execute the previously completed tasks. There are additional features 'status', 'preconditions' and 'if' that may also be used.

    If you have a particularly flaky command, simply use a shell loop. They are easy to write, concise and capable. But otherwise, use the existing features of Task.

  3. ssbarnea commented on Jun 10, 2026

    @ssbarnea
    Contributor

    This is marked as done but from the thread I don't see a clear pattern on how to implement a retry logic. I think that the subject is important enough to at least have an example inside the docs.

    I am facing some flaky CI issues with a particular step and running it with retries can prove very useful. Using shell loop is not an option when you run taskfile across all 3 major architectures.

  4. tbrandenburg commented on Oct 24, 2026

    @tbrandenburg

    I would like to revisit native retries, particularly for flaky tasks used in CI/CD and nested task workflows.

    The existing sources, generates, and run features help avoid repeating completed work, but they do not provide retry semantics for a failed operation.

    Shell loops work as a workaround, but they make retry policies harder to reuse, configure, and observe consistently across Taskfiles.

    Would you consider a small, opt-in retry policy such as:

    version: '3'
    tasks:
      upload:
        retry:
          attempts: 3
          delay: 2s
          backoff: 2
          exit_codes: [1, 75]
        cmds:
          - upload-artifact
    

    This is illustrative syntax, not an existing feature.

    Some useful semantics would be:

    • A defined maximum number of attempts, including the initial attempt.
    • Optional delay and exponential backoff.
    • Optional filtering by exit code.
    • A clear choice between retrying a failed command and restarting an entire task.
    • Per-attempt logging for troubleshooting and future tracing integrations.
    • No automatic re-execution of already successful dependencies.

    I understand that retries can be unsafe for commands with side effects, so this should be explicitly opt-in.

    Would you as maintainers be open to reconsidering this as a narrowly scoped enhancement? Or is native retry support intentionally outside Task’s scope?

  5. trulede commented on Oct 25, 2026

    @trulede
    Contributor

    @tbrandenburg did you ever try curl? Something like this:

    version: '3'
    
    tasks:
      upload-put:
        desc: Uploads an artifact using PUT with 3 retries and exponential backoff
        cmds:
          - >
            curl -f -sSL 
            -T artifact.tar.gz 
            --retry 3 
            --retry-all-errors 
            https://example.com
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for feature.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions