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

after_failure script not run if script errors #8038

Closed
lwaldron opened this issue Jul 5, 2017 · 8 comments
Closed

after_failure script not run if script errors #8038

lwaldron opened this issue Jul 5, 2017 · 8 comments
Assignees

Comments

@lwaldron
Copy link

lwaldron commented Jul 5, 2017

@craigcitro @hadley @jimhester I have the following in my .travis.yml file for an R package at https://github.com/waldronlab/curatedMetagenomicDataCuration. The .push_gh_pages.sh script runs after a successful package check, but not after a package check where the unit tests produce any error. I've left the package intentionally in an erroring state because I want ./push_gh_pages.sh to run even if the unit tests fail (actually, especially if the unit tests fail, because the vignette is designed to help identify the reason for failure).

after_script:
  - ./.push_gh_pages.sh
after_failure:
  - ./.push_gh_pages.sh
@BanzaiMan
Copy link
Contributor

Looks like the build script is bailing out early, without a chance for travis-build to clean up. https://github.com/travis-ci/travis-build/blob/97c7efd0cd1102bbcaaf896536f2ff236687c9df/lib/travis/build/script/r.rb#L239

@lwaldron
Copy link
Author

I'm now working around this issue by using a before_script script to build and push to gh-pages before the travis-CI R script is run. FYI this previous version shows how I was originally trying to run a script after success or failure.

@chris-ratcliffe
Copy link

@BanzaiMan I am seeing this issue as well. In my script section I include a call to set -e to force processing to stop when any particular command fails, however, that seems to cause the "bail out" to happen, in which case, neither after_script nor after_failure run. If I remove the set -e, both of them run when there is a failure, however, I then have all of my unnecessary steps after the failure continue to run. Is there now way to cause the script section to stop on failure, and make use of the after_* sections?

@ericchenshine
Copy link

Is there any update on this issue?

@BanzaiMan
Copy link
Contributor

Sorry, but I have no updates.

@jimhester
Copy link

@BanzaiMan Is there a different way to signal failure that would still execute the after_failure block? I can change the script if so.

@BanzaiMan
Copy link
Contributor

At the moment there is not, I'm afraid.

@dotmpe
Copy link

dotmpe commented Mar 17, 2018

I was a bit confounded about an issue with the same behaviour. Until I read the comment by @chris-ratcliffe.

Forgot about some scripts sourced into the build shell, which set -e at the beginning. Problems went away by reversing exit on error again set +e.

It would be useful to mention in the docs, not only about error-on-exit but also advising against using exit and prefer to return. There is an issue on that, maybe if Ihave some time later. travis-ci/docs-travis-ci-com#1672

https://travis-ci.org/bvberkum/script-mpe/builds/354613175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants