Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abitrolly opened this issue Oct 4, 2022 · 6 comments
Open

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

abitrolly opened this issue Oct 4, 2022 · 6 comments
Labels
feature: gitpod yml All things related to the gitpod.yml feature: tasks meta: never-stale This issue can never become stale team: IDE type: feature request New feature or request

Comments

@abitrolly
Copy link

abitrolly commented Oct 4, 2022

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.

@abitrolly abitrolly changed the title tasks: Fail on error by defaul (run with with bash -e) tasks: Fail on error by default (run with with bash -e) Oct 4, 2022
@abitrolly abitrolly changed the title tasks: Fail on error by default (run with with bash -e) tasks: Fail on error by default (run with bash -e) Oct 4, 2022
@axonasif axonasif added feature: tasks feature: gitpod yml All things related to the gitpod.yml team: IDE labels Oct 4, 2022
@akosyakov
Copy link
Member

I guess it could be alright to run like that in prebuild workspaces, but in regular workspaces it will close a terminal on first errored statement.

@abitrolly
Copy link
Author

abitrolly commented Oct 4, 2022

@akosyakov is it possible leave terminal open with a message that the task it terminated, listing failed step and instructions how to continue or restart the task? That would be in ideal UX.

@akosyakov
Copy link
Member

Have you tried to create a shell script and do set -e there and the run it from init: ./.gitpod/my-init.sh? I would think you will have the entire control like that?

@abitrolly
Copy link
Author

@akosyakov I can move everything into separate script, wrap into (set -e; ...) as instructed by docs, but that won't be the default behavior anymore.

@stale
Copy link

stale bot commented Jan 2, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the meta: stale This issue/PR is stale and will be closed soon label Jan 2, 2023
@stale stale bot closed this as completed Jun 12, 2023
@abitrolly
Copy link
Author

This is not completed.

@akosyakov akosyakov reopened this Jun 19, 2023
@akosyakov akosyakov added the meta: never-stale This issue can never become stale label Jun 19, 2023
@stale stale bot removed the meta: stale This issue/PR is stale and will be closed soon label Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: gitpod yml All things related to the gitpod.yml feature: tasks meta: never-stale This issue can never become stale team: IDE type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants