# Capistrano: creating your own tasks

**URL:** <https://www.ruby-forum.com/t/capistrano-creating-your-own-tasks/55540>\
**Category:** Rails\
**Created:** [March 22, 2006, 12:52am UTC](https://www.ruby-forum.com/t/capistrano-creating-your-own-tasks/55540 "2006-03-22T00:52:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@johnk](https://www.ruby-forum.com/u/johnk)\
**Post date:** [March 22, 2006, 12:52am UTC](https://www.ruby-forum.com/t/capistrano-creating-your-own-tasks/55540/1 "2006-03-22T00:52:48Z")

</div>

When I create a task within capistrano.rb I can call it using rake.

When I create a task and put it in deploy.rb I can call it. Neither  
with or without the remote: namespace.

Anyone have any insight into why it does not work?

John K.

---

<div class="post-metadata">

**Author:** ![johnk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@johnk](https://www.ruby-forum.com/u/johnk)\
**Post date:** [March 22, 2006, 6:24am UTC](https://www.ruby-forum.com/t/capistrano-creating-your-own-tasks/55540/2 "2006-03-22T06:24:49Z")

</div>

On Mar 21, 2006, at 4:52 PM, John K. wrote:

> When I create a task within capistrano.rb I can call it using rake.
> 
> When I create a task and put it in deploy.rb I can call it.  
> Neither with or without the remote: namespace.
> 
> Anyone have any insight into why it does not work?

Above, you say “I can call it”. Do you mean “can’t”?

First, you need to be sure and keep “rake tasks” and “cap tasks”  
separate. Rake cannot execute capistrano tasks directly. Capistrano  
cannot invoke rake tasks directly.

If you have a capistrano task, it needs to go in deploy.rb. If you  
want to be able to invoke it via rake, you then need to add a wrapper  
for it in lib/tasks/capistrano.rake.

Try this. In config/deploy.rb, add the following:

task :test\_task do  
puts “IT’S ALIVE!!!”  
end

Then, type:

cap test\_task

Do you see the “IT’S ALIVE” message?

- Jamis

---

<div class="post-metadata">

**Author:** ![johnk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@johnk](https://www.ruby-forum.com/u/johnk)\
**Post date:** [March 22, 2006, 5:55pm UTC](https://www.ruby-forum.com/t/capistrano-creating-your-own-tasks/55540/3 "2006-03-22T17:55:53Z")

</div>

Again Jamis, thanks a lot. I now have a perfectly customized task to  
upload my website. Sweet! 🙂

On 22-Mar-06, at 12:23 AM, Jamis B. wrote:

> task :test\_task do
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

John K.
