问题
I have an open source project that I'd like to test using travis-ci. Sadly it is rather flaky and I'd like to know the reason. The tests write very verbose log files, so I'd like to export these, upon failure to Github Gist. There are command line tools that allow me to do that, gist-paste
for instance, however I don't know how to run them only upon failure and without overriding the return code of the unittests, i.e., I'd still like travis-ci to notice the failure.
回答1:
Great idea. Travis CI has a step in the build lifecycle called after_failure
which will be fired after your testing script
step has run and failed, as outlined on the "customizing the build" documentation page here.
In your .travis.yml
file, you would add an after_failure
step with a call to your gist-paste
command, after setting the relevant Git tokens as encrypted environment variables I assume. You can then access plenty of information about the build from the many environment variables set by Travis during the build.
来源:https://stackoverflow.com/questions/40181218/upload-gist-upon-travis-ci-failure