Capistrano Rollback
In this tutorial we will see how we can rollback Capistrano deployment or Capistrano Rollback. Capistrano is a framework for building automated deployment scripts. Although Capistrano itself is written in Ruby, it can easily be used to deploy projects of any language or framework, be it Rails, Java, or PHP.
Capistrano Rollback
Firstly we will see how to rollback the deployment using Capistrano. Capistrano made easy to deploy and rollback.
cap production deploy:rollback
The above command will rollback the previous version that was deployed by Capistrano.
Capistrano Rollback specific version
Now we will see how we can rollback specific release using Capistrano. In first step we will list all the releases available then we will rollback the specific release.
You can also visit: Show current release in Capistrano
You can use the following rake to get the current release version of the Capistrano. You just need to create a file in config/lib/capistrano/tasks/list_release.rake
vim config/lib/capistrano/tasks/list_release.rake
After creating a file copy the following and add into the file and replace the path with yours and save the file.
namespace :list do
desc 'Show deployed revision'
task :release do
on roles(:app) do
execute "ls -ltr /var/www/app/current"
end
end
end
Check the list of releases
After creating a rake file now it’s time to check the current release version. Execute the following command:
cap stage-name list:release
You will get list of releases available.
You might also like: Test shell Script in CircleCI
Rollback specific release
Now you will following command to rollback the specific release or version. Replace (release-number) with release number from last command.
cap production deploy:rollback ROLLBACK_RELEASE=(release-number)
Now it will start rollback to the release that you specified.
If you get any issues using this tutorial please feel free to comment below.
https://installvirtual.com/capistrano-show-current-release-version/