I know the primary travis build logs are available on the web and with the logs
command in the travis command line client, but I was wondering if there is a way to access other files generated as part of the build process, such as the file /home/travis/.rvm/log/1391454748_rbx-2.2.4/rubygems.install.log
referenced in https://travis-ci.org/rspec/rspec-its/jobs/18148204
问题:
回答1:
Those files are lost once the build is finished. If you want to read them, you should add a cat
command to print out to the log you see.
before_script: cat /home/travis/.rvm/log/*_rbx-2.2.4/rubygems.install.log
If the install command is failing, then you should override install
to install the gem for which the installation is failing:
install: gem install XXX || cat /home/travis/.rvm/log/*_rbx-2.2.4/rubygems.install.log
回答2:
banzaiman's answer is good (it helped me!). But if you use:
install: gem install XXX || cat /home/travis/.rvm/log/*_rbx-2.2.4/rubygems.install.log
then the cat
command will likely succeed, and so the line above will count as as success, and the build will continue. If you want the build to fail when the install fails, then you need to make sure the line has a non-zero exit status. So do something like this:
install: gem install XXX || { cat /home/travis/.rvm/log/*_rbx-2.2.4/rubygems.install.log && 1; }
The expression in curly braces will be run only if the gem install XXX
fails (i.e., has a non-zero exit status). cat
will presumably succeed, so the command after the &&
will be run. That 1
ensures a non-zero exit status for the whole line, causing the build to stop at that point.
Note the necessary whitespace around the curly braces.