Ruby on Rails, or just Rails, is one of the most popular model-view-controller frameworks in use on the web today. Developed in 2005 by David Heinemeier Hansson (co-founder of Basecamp), it set the precedent for a number of features found in most other MVC frameworks, such as database table creating and view scaffolding, allowing apps to be rapidly created from the structure of the database.
Rails works amazingly with Travis CI, so let’s get you building even faster!
Let’s put Travis on Rails!
You’ll obviously want to signup for Travis, be sure to sync your account, open your
Gemfile and add:
Run any migrations you may need to make, then:
In this use case, we are creating the
You don’t in theory need to specify a Ruby version, Travis will look at your
ruby-, but you can definitely specify a Ruby version if you chose to:
language: ruby dist: xenial rvm: 2.5.8
That tells Travis what language (Ruby), what
dist you’ll be using (also can be changed) and
rvm the version of Ruby you’ll be using. You can now add
script which is commands you’re telling Travis to run when you triggered a build, so it could look like the following:
script: — bundle install — jobs=3 — retry=3 — bundle exec rake db:create — bundle exec rake db:migrate — bundle exec rspec
You can then check your
.travis.yml’s validity via the linting online application Travis Lint, or do it manually:
Then commit changes and see your Rails app build! We push to GitHub, we’ll be doing this in a variety of different ways in the upcoming Cookbook entries, so you’ll have a choice on how you’d like to deploy!
git init git add . git commit -m "Travis build" git remote add origin remote repository URL git remote -v git push -u origin master
That’s it, you’re setup. Travis is on Rails. We have new recipes every other week, so make sure you come back next week for a practical way of using Travis CI!
Not a Travis CI user yet? Sign up for a free account!
Looking for something more bespoke for your builds? Try a free trial of Travis CI Enterprise.