I'm been able to make use of the basic capistrano-ext multistage
functionality and deploy common tasks based on environment
successfully, but what I'm aiming to do is to customize the deployment
tasks that get invoked based on the environment. That is to say, I can
customize behaviour based on the variables I set in the stage (ie:
development/staging/production) task , but I would also like to
customize behaviour a bit further using after: hooks.

In response to my initial post you replied

-- snip --
Just put your before/after declarations in the corresponding stage
file.
E.g., in config/deploy/production.rb, say:
   after "deploy:update", "upload_static_assets_to_s3"
etc.
-- snip --

which, if it worked, would have answered my question.

Buoyed by your reply, I added some tasks to my main deploy.rb file and
aimed to customize my deployment by adding some after
"deploy:update_code" hooks to the stage files in config/deploy/ -- eg.
my development.rb invokes the task that links the attachment-fu folder
to a folder on the filesystem, whereas staging.rb and production.rb
both call the task that configures attachment-fu for S3.

As I tried to communicate in my earlier post (on Thu, 16 Apr 2009), it
doesn't seem as if the stage files are actually being loaded. I'm not
sure how to get capistrano to recognize the files generated by cap
multistage:prepare.

Is there a problem with the approach of 1. defining all tasks in
deploy.rb then 2. customizing deployments for specific environments
using hooks in the appropriate stage file ?


- Ivar


On Apr 16, 6:10 pm, Jamis Buck <[email protected]> wrote:
> Each stage essentially becomes it's own task, so in order to invoke a
> task in the environment of a particular stage, you need to specify that
> stage:
>
>    cap production deploy
>    cap staging deploy:pending
>
> etc.
>
> - Jamis
>
> On 4/16/09 6:22 PM, Ivar Vasara wrote:
>
> > Jamis,
>
> > That looks like a perfect solution. I've followed your suggestion and
> > added the after "deploy:update" hook to config/deploy/staging.rb but
> > the stage files don't seem to be parsed.  Unfortunately, I haven't
> > been able to find any documentation or notes about capistrano-ext
> > supporting the various stage files. To be honest, your reply was the
> > first I'd heard of the stage file feature, but inspired by your
> > solution I poked around and noticed the multistage:prepare task, which
> > I must have missed earlier. I started a post here, but figured I
> > should poke around the source a bit to understand my issue.. in I got
> > to (line 15 from multistage.rb in capistrano-ext on github):
>
> >    stages.each do |name|
> >      desc "Set the target stage to `#{name}'."
> >      task(name) do
> >        set :stage, name.to_sym
> >        load "#{location}/#{stage}"
> >      end
> >    end
>
> > and it appears that the code inside the second 'do' is never
> > executed.. I haven't dug deep enough to know what's wrong but that
> > code has been there for ages, so it must be something to do with my
> > environment, but I can't tell what. The 'stages' array appears to be
> > set correctly by the time it gets to that code, but in config/deploy I
> > have three files - dev.rb, staging.rb and production.rb - none of
> > which are read.
>
> > Any help/pointers appreciated.
>
> > On Apr 10, 7:26 am, Jamis Buck<[email protected]>  wrote:
> >> Just put your before/after declarations in the corresponding stage file.
> >> E.g., in config/deploy/production.rb, say:
>
> >>     after "deploy:update", "upload_static_assets_to_s3"
>
> >> etc.
>
> >> - Jamis
>
> >> On 4/10/09 8:00 AM, ivar vasara wrote:
>
> >>> I've been using Capistrano for some time now, but one thing I haven't
> >>> been able to figure out is how to conditionally invoke tasks based on
> >>> environment. For example, on production there are additional
> >>> configurations to be made and static assets to be uploaded to s3. I'm
> >>> using the cap-ext plugin successfully, but being able to add before/
> >>> after filters based on environment would be a big win. Is there a
> >>> standard way of doing this ?
>
>
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to