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

init task doesn't stop on failure #13520

Closed
abitrolly opened this issue Oct 3, 2022 · 2 comments
Closed

init task doesn't stop on failure #13520

abitrolly opened this issue Oct 3, 2022 · 2 comments
Labels

Comments

@abitrolly
Copy link

Bug description

Gitpod doesn't stop with an error when init task command fails.

Steps to reproduce

In the .gitpod.yml below (for Ruby project) gitpod/workspace-ruby-2 image comes without yarn, but init script continues to run after yarn install failed.

image: gitpod/workspace-ruby-2

tasks:
  - init: |
      bundle install
      yarn install --frozen-lockfile
      bundle exec rake
      bundle exec nanoc compile
    command: bundle exec nanoc live --port=3004

Workspace affected

abitrolly-gitlabdocs-1ymjgt70jro

Expected behavior

Failure and stopping after yarn install would make it much easier to spot and debug errors.

Example repository

https://gitlab.com/gitlab-org/gitlab-docs/ (it might be fixed soon)

Anything else?

No response

@abitrolly abitrolly added the type: bug Something isn't working label Oct 3, 2022
@axonasif axonasif added feature: prebuilds feature: tasks team: webapp Issue belongs to the WebApp team labels Oct 3, 2022
@axonasif
Copy link
Member

axonasif commented Oct 3, 2022

Hi @abitrolly, all your tasks run inside separate bash (?$SHELL) shells. Gitpod can only assert the exit status of the $SHELL process. Normally bash or other shells don't halt on a failure of a command unless you explicitly ask it to. Since your last command bundle exec nanoc compile is not exiting with a non-zero code, so bash also inherits that before it's own exit. Hence Gitpod can't determine if all of your commands inside the init task succeeded. To have that effect, you can put set -e; on top of your init: | shell-commands to configure that particular task shell to halt and immediately exit with an error code for a failure of any command.

@abitrolly
Copy link
Author

Hi @axonasif. Thanks for the explanation. I filled a request #13558 to invert the default behavior to what, I believe, most CI/CD users expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Validation
Development

No branches or pull requests

2 participants