Search code examples
ruby-on-railsassetstravis-ci

How can I precompile assets using Travis CI?


In the rails guides they have an example on how to precompile assets with Capistrano. It is as simple as adding load 'deploy/assets' to the Capfile. I simply want to achieve the same effect, precompiling assets, while using Travis CI instead. This is what I've done so far:

script/travis.sh:

run "bundle exec rake assets:precompile"

.travis.yml:

 before_install:
  - chmod +x script/travis.sh
 script: script/travis.sh
 language: ruby
 rvm:
 - 2.2
 deploy:
   provider: heroku

When this is built on Travis it fails and I get this from the log:

$ script/travis.sh
script/travis.sh: line 1: run: command not found
The command "script/travis.sh" exited with 127.

I also want to add that my shell script knowledge is very limited.


Solution

  • I'm not entirely sure, but I'm leaning towards the run command not being available in the travis shell, as against Capistrano. I'd say you should probably just leave your travis.sh as:

    bundle exec rake assets:precompile
    

    And try again. Let me know the results of that