.travis.yml finally working correctly with conditionals. Slight refactoring of code and adding an exit statement to after_script.