Skip to content

tasks: Fail on error by default (run with bash -e) #13558

Open
@abitrolly

Description

@abitrolly

Is your feature request related to a problem? Please describe

Gitpod multiline tasks don't fail if the failed command is in the middle (#13520).

For example, this inevitable failure will result in great success.

- init: |
    echo The failure is inevitable.
    true
    false
    true
    echo Unachievable great success."

Which is equivalent to this bash call.

$ bash -c "echo The failure is inevitable.   
  true
  false
  true
  echo Unachievable great success."
The failure is inevitable.
Unachievable great success.

https://github.com/gitpod-io/website/pull/2843 adds an explanation with a code snippet that users need to copy paste if they want to amend this behavior and fail on errors. The problem is, all other CI/CD systems that are configured by YAML, such as GitHub Actions, fail on multiline strings by default.

Describe the behaviour you'd like

The solution is to add -e option to bash when task is executed. Then the execution will be equal to this behavior.

$ bash -e -c "echo The failure is inevitable.
  true
  false
  true
  echo Unachievable great success."
The failure is inevitable.

The example at the https://github.com/gitpod-io/website/pull/2843 then could be altered to show how modify scripts to ignore failures.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions