Skip to content

Compatibility of preconditions & ignore_error #2687

@butuzov

Description

@butuzov

Description

I tried to add dependency on a tool for developers, however its failing if i use precondition.

Case o failure

tasks:
  tests:
    desc: run tests
    cmds:
    - task: install:tparse
      ignore_error: true
    - go test -v -json ./... | go tool tparse --all

  install:tparse:
    preconditions: [ "go tool | grep -q tparse && exit 1 || exit 0" ]
    cmd: go get -tool github.com/mfridman/tparse@latest
    ignore_error: true # this also do nothing
    silent: true #aswell as silent ignored

Results in

 > task backend:tests
task: `go tool | grep -q tparse && exit 1 || exit 0` failed
task: Failed to run task "backend:tests": task: Failed to run task "backend:install:tparse": task: precondition not met

Case o success

while

tasks:
  tests2:
    cmds:
    - task: fail
      ignore_error: true
    - echo "works?"

  fail:
    cmd: sh 1
    silent: true

Results in

 > task backend:tests2
sh: 1: No such file or directory
task: [backend:tests2] echo "works?"
works?

So, why does having precondition for running of the tasks failng whole pipeline?

Version

3.48.0

Operating system

macOS

Experiments Enabled

No response

Example Taskfile

version: 3

tasks:
  tests:
    desc: run tests
    cmds:
    - task: install:tparse
      ignore_error: true
    - go test -v -json ./... | go tool tparse --all

  install:tparse:
    preconditions: [ "go tool | grep -q tparse && exit 1 || exit 0" ]
    cmd: go get -tool github.com/mfridman/tparse@latest
    ignore_error: true # this also do nothing
    silent: true #aswell as silent ignored

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions