This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Deployment with Capistrano!
You have completed Deployment with Capistrano!
Create and run a simple Capistrano task.
From your development machine's terminal:
rails new captest
In the new app's Gemfile
, uncomment the capistrano-rails
entry.
Change into the app's directory and run:
bundle install
bundle exec cap install
This will generate the following configuration files:
-
Capfile
- Used for including required libraries
- We'll just use defaults for now
-
config/deploy.rb
- Set configuration variables
set :message, "Hello, Capistrano!"
-
config/deploy/{staging,production}.rb
- Defines a stage, as in
cap STAGENAME deploy
- Define servers for a stage
- Define variables specific to a stage
- We'll just be defining a server here
- Defines a stage, as in
server "<YOUR HOST ADDRESS HERE>", user: "deploy", roles: ["greeter"]
-
lib/capistrano/tasks/*.rake
(Note that's.rake
, not.rb
)- Define tasks
desc "Write a message to a file"
task :write_message do
on roles(:greeter) do
execute "echo '#{fetch :message}' >> ~/message.txt"
end
end
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up