Bil Kleb
2009-May-22 23:06 UTC
[Cruisecontrolrb-users] build trigger chaining (build same revision for entire chain)
Hi,
Does anyone know how to (or have a patch for) chaining a
series of builds so that each build in the chain builds
the triggering build''s revision and not the latest revision
available from source control?
We have a series of builds that, if they all pass, the
final one builds a release.
This was my patch to 1.2.1,
*** cruisecontrolrb-1.2.1/app/models/successful_build_trigger.rb
2007-11-04 15:06:49.000000000 -0500
--- cruisecontrolrb-1.2.1-hacked/app/models/successful_build_trigger.rb
2008-04-04 06:58:28.000000000 -0400
***************
*** 16,22 ****
[]
else
@last_successful_build = new_last_successful_build
! [@triggered_project.last_locally_known_revision]
end
end
--- 16,22 ----
[]
else
@last_successful_build = new_last_successful_build
! [Revision.new(@last_successful_build.revision)]
end
end
but I''m failing to see how to translate this to 1.3.x.
Thanks,
--
Bil Kleb
http://fun3d.larc.nasa.gov
Chad Woolley
2009-May-23 06:13 UTC
[Cruisecontrolrb-users] build trigger chaining (build same revision for entire chain)
On Fri, May 22, 2009 at 4:06 PM, Bil Kleb <Bil.Kleb at nasa.gov> wrote:> but I''m failing to see how to translate this to 1.3.x.Check Project#build_if_necessary It says: return build(source_control.latest_revision, reasons) This now hardcodes to build the latest revision. To accomplish what you want, maybe you could add a #revision_to_build property on SuccessfulBuildTrigger, and use that instead of latest_revision. This would be an API change to the trigger, though, so you''d probably want to default to the latest revision if there was no #revision_to_build property or it was nil. -- Chad
Bil Kleb
2009-Jul-21 10:05 UTC
[Cruisecontrolrb-users] build trigger chaining (build same revision for entire chain)
Chad Woolley wrote:> > Check Project#build_if_necessary > It says: return build(source_control.latest_revision, reasons) > > This now hardcodes to build the latest revision. > > To accomplish what you want, maybe you could add a #revision_to_build > property on SuccessfulBuildTrigger, and use that instead of > latest_revision. This would be an API change to the trigger, though, > so you''d probably want to default to the latest revision if there was > no #revision_to_build property or it was nil.Thanks for the sketch. For posterity''s sake, here''s the hack we cobbled together: diff --git a/app/models/project.rb b/app/models/project.rb index 5784d2e..e6c23a6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -210,7 +210,11 @@ class Project begin if build_necessary?(reasons = []) remove_build_requested_flag_file if build_requested? - return build(source_control.latest_revision, reasons) + revision = source_control.latest_revision + if (triggered_by.first.respond_to?(:revision_to_build) ) + revision = triggered_by.first.revision_to_build + end + return build(revision, reasons) else return nil end @@ -523,4 +527,4 @@ def plugin_loader.load_all end -plugin_loader.load_all \ No newline at end of file +plugin_loader.load_all diff --git a/app/models/successful_build_trigger.rb b/app/models/successful_build_trig index a768332..7816a79 100644 --- a/app/models/successful_build_trigger.rb +++ b/app/models/successful_build_trigger.rb @@ -40,6 +40,11 @@ class SuccessfulBuildTrigger @triggering_project = Project.new(value.to_s) end + def revision_to_build + number = last_successful(@triggering_project.builds).revision + SourceControl::Subversion::Revision.new(number) + end + private Regards, -- Bil Kleb http://fun3d.larc.nas.gov