public
Description: CruiseControl.rb is a continuous integration tool, written in Ruby. It is quick to install, simple to use and easy to hack.
Homepage: http://cruisecontrolrb.thoughtworks.com/
Clone URL: git://github.com/benburkert/cruisecontrolrb.git
first cut of build chaining

git-svn-id: http://cruisecontrolrb.rubyforge.org/svn/trunk@452 
c04ce798-636b-4ca8-9149-0f9336831111
stellsmi (author)
Mon Apr 09 09:35:48 -0700 2007
commit  a63e4d9578d0798a3e86db6e7c90aa280b72a0d6
tree    a8fbb301e3a7ffca77c5f715dabf2adc4fefc13e
parent  c553d8d2c67464d6b69832d1dda823f512a0f499
...
73
74
75
76
77
78
79
80
81
82
83
84
...
73
74
75
 
 
 
 
 
 
76
77
78
0
@@ -73,12 +73,6 @@ EOF
0
   def status
0
     build_status.to_s
0
   end
0
-
0
- def status=(value)
0
- FileUtils.rm_f(Dir["#{artifacts_directory}/build_status.*"])
0
- FileUtils.touch(artifact("build_status.#{value}"))
0
- build_status = value
0
- end
0
 
0
   def successful?
0
     build_status.succeeded?
...
1
 
 
 
 
2
3
4
5
6
7
8
 
9
10
11
12
 
13
14
15
16
 
17
18
19
20
 
21
22
23
24
 
25
26
27
28
29
30
 
31
32
33
...
69
70
71
72
 
73
74
75
76
77
78
79
 
80
81
82
...
1
2
3
4
5
6
7
8
9
10
11
 
12
13
14
15
 
16
17
18
19
 
20
21
22
23
 
24
25
26
27
 
28
29
30
31
32
33
 
34
35
36
37
...
73
74
75
 
76
77
78
79
80
81
82
 
83
84
85
86
0
@@ -1,33 +1,37 @@
0
 class BuildStatus
0
+ SUCCESS = 'success'
0
+ FAILED = 'failed'
0
+ INCOMPLETE = 'incomplete'
0
+ NEVER_BUILT = 'never_built'
0
   
0
   def initialize(artifacts_directory)
0
     @artifacts_directory = artifacts_directory
0
   end
0
   
0
   def never_built?
0
- read_latest_status == 'never_built'
0
+ read_latest_status == NEVER_BUILT
0
   end
0
   
0
   def succeeded?
0
- read_latest_status == 'success'
0
+ read_latest_status == SUCCESS
0
   end
0
   
0
   def incomplete?
0
- read_latest_status == 'incomplete'
0
+ read_latest_status == INCOMPLETE
0
   end
0
   
0
   def failed?
0
- read_latest_status == 'failed'
0
+ read_latest_status == FAILED
0
   end
0
   
0
   def succeed!(elapsed_time)
0
- FileUtils.mv @artifacts_directory, "#{@artifacts_directory}-success.in#{elapsed_time}s"
0
+ FileUtils.mv @artifacts_directory, "#{@artifacts_directory}-#{SUCCESS}.in#{elapsed_time}s"
0
   end
0
   
0
   def fail!(elapsed_time, error_message=nil)
0
     error_message_file = File.join(@artifacts_directory, "error.log")
0
     File.open(error_message_file, "w+"){|f| f.write error_message } if error_message
0
- FileUtils.mv @artifacts_directory, "#{@artifacts_directory}-failed.in#{elapsed_time}s"
0
+ FileUtils.mv @artifacts_directory, "#{@artifacts_directory}-#{FAILED}.in#{elapsed_time}s"
0
   end
0
   
0
   def created_at
0
@@ -69,13 +73,13 @@ class BuildStatus
0
   private
0
   
0
   def read_latest_status
0
- return 'never_built' unless File.exist? @artifacts_directory
0
+ return NEVER_BUILT unless File.exist? @artifacts_directory
0
     match_status(@artifacts_directory).downcase
0
   end
0
   
0
   def match_status(dir_name)
0
     a = dir_name.split("-")
0
     return a.last.split(".").first if a.size > 2
0
- return "incomplete"
0
+ return INCOMPLETE
0
   end
0
 end
0
\ No newline at end of file
...
1
 
2
3
4
...
38
39
40
 
41
42
43
...
145
146
147
 
 
 
 
 
 
148
149
150
...
193
194
195
196
197
198
 
 
199
200
201
...
1
2
3
4
5
...
39
40
41
42
43
44
45
...
147
148
149
150
151
152
153
154
155
156
157
158
...
201
202
203
 
204
 
205
206
207
208
209
0
@@ -1,4 +1,5 @@
0
 require 'fileutils'
0
+require 'triggers'
0
 
0
 class Project
0
   @@plugin_names = []
0
@@ -38,6 +39,7 @@ class Project
0
     @settings = ''
0
     @config_file_content = ''
0
     @error_message = ''
0
+ @trigger = ChangeInSourceControlTrigger.new
0
     instantiate_plugins
0
   end
0
   
0
@@ -145,6 +147,12 @@ class Project
0
     builds.last
0
   end
0
   
0
+ def create_build(label)
0
+ build = Build.new(self, label)
0
+ build.artifacts_directory # create the build directory
0
+ build
0
+ end
0
+
0
   def previous_build(current_build)
0
     all_builds = builds
0
     index = get_build_index(all_builds, current_build.label)
0
@@ -193,9 +201,9 @@ class Project
0
   end
0
 
0
   def build_if_necessary
0
- notify :polling_source_control
0
     begin
0
- revisions = new_revisions
0
+ revisions = @trigger.get_revisions_to_build(self)
0
+
0
       if revisions.empty?
0
         notify :no_new_revisions_detected
0
         return nil
...
9
10
11
 
 
 
 
12
13
14
...
9
10
11
12
13
14
15
16
17
18
0
@@ -9,6 +9,10 @@ Revision #{number} committed by #{committed_by} on #{time.strftime('%Y-%m-%d %H:
0
     EOL
0
   end
0
 
0
+ def ==(other)
0
+ number == other.number
0
+ end
0
+
0
   def to_i
0
     number
0
   end
...
4
5
6
 
7
...
4
5
6
7
8
0
@@ -4,4 +4,5 @@
0
 
0
 Project.configure do |project|
0
   project.email_notifier.emails = ["cruisecontrol-developers@rubyforge.org"]
0
+# project.triggered_by successful_build_of(:cruise_control_fast)
0
 end
...
3
4
5
6
7
 
 
8
9
10
...
3
4
5
 
 
6
7
8
9
10
0
@@ -3,8 +3,8 @@
0
 # in order to make cruise run as daemon, you need:
0
 # 1. cp $CCRB_HOME/daemon/cruise.sample $CCRB_HOME/daemon/cruise
0
 # 2. specify your cruise_path to $CCRB_HOME in $CCRB_HOME/daemon/cruise file
0
-# 3. ln -s $CCRB_HOME/daemon/cruise /etc/init.d/cruise (you may need sudo this)
0
-# 4. update-rc.d cruise (you may want to choose options by yourself, and you may need sudo this)
0
+# 3. ln -s $CCRB_HOME/daemon/cruise /etc/init.d/cruise (you may need to 'sudo' this)
0
+# 4. update-rc.d cruise (you may want to choose options by yourself, and you may need to 'sudo' this)
0
 # 5. it's done :>
0
 
0
 require "fileutils"
...
77
78
79
80
 
81
82
83
...
77
78
79
 
80
81
82
83
0
@@ -77,7 +77,7 @@ begin
0
     write_to_log_and_console "Builder for project '#{project.name}' started"
0
     puts "Logging to: #{File.expand_path(CRUISE_OPTIONS[:log_file_name])}"
0
 
0
- while (true) do
0
+ while (true) do
0
       catch(:reload_project) do
0
         project.scheduler.run
0
       end
...
5
6
7
8
9
10
11
...
17
18
19
20
 
21
22
23
...
54
55
56
57
58
59
60
61
62
 
 
 
 
 
 
63
64
65
...
70
71
72
73
74
 
 
75
76
77
...
5
6
7
 
8
9
10
...
16
17
18
 
19
20
21
22
...
53
54
55
 
 
 
 
 
 
56
57
58
59
60
61
62
63
64
...
69
70
71
 
 
72
73
74
75
76
0
@@ -5,7 +5,6 @@ class BuildTest < Test::Unit::TestCase
0
 
0
   def test_initialize_should_load_status_file_and_build_log
0
     with_sandbox_project do |sandbox, project|
0
- sandbox.new :file => "build-2-success.in9.235s/build_status.success.in9.235s"
0
       sandbox.new :file => "build-2-success.in9.235s/build.log", :with_content => "some content"
0
       build = Build.new(project, 2)
0
   
0
@@ -17,7 +16,7 @@ class BuildTest < Test::Unit::TestCase
0
 
0
   def test_initialize_should_load_failed_status_file
0
     with_sandbox_project do |sandbox, project|
0
- sandbox.new :file => "build-2-failed.in2s/build_status.failed.in2s"
0
+ sandbox.new :directory => "build-2-failed.in2s"
0
       build = Build.new(project, 2)
0
   
0
       assert_equal 2, build.label
0
@@ -54,12 +53,12 @@ class BuildTest < Test::Unit::TestCase
0
   
0
   def test_successful?
0
     with_sandbox_project do |sandbox, project|
0
- sandbox.new :file => "build-1-success/build_status.success"
0
- sandbox.new :file => "build-2-Success/build_status.Success"
0
- sandbox.new :file => "build-3-failure/build_status.failure"
0
- sandbox.new :file => "build-4-crap/build_status.crap"
0
- sandbox.new :file => "build-5/foo"
0
-
0
+ sandbox.new :directory => "build-1-success"
0
+ sandbox.new :directory => "build-2-Success"
0
+ sandbox.new :directory => "build-3-failure"
0
+ sandbox.new :directory => "build-4-crap"
0
+ sandbox.new :directory => "build-5"
0
+
0
       assert Build.new(project, 1).successful?
0
       assert Build.new(project, 2).successful?
0
       assert !Build.new(project, 3).successful?
0
@@ -70,8 +69,8 @@ class BuildTest < Test::Unit::TestCase
0
 
0
   def test_incomplete?
0
     with_sandbox_project do |sandbox, project|
0
- sandbox.new :file => "build-1-incomplete/build_status.incomplete"
0
- sandbox.new :file => "build-2-something_else/build_status.something_else"
0
+ sandbox.new :directory => "build-1-incomplete"
0
+ sandbox.new :directory => "build-2-something_else"
0
   
0
       assert Build.new(project, 1).incomplete?
0
       assert !Build.new(project, 2).incomplete?
...
476
477
478
479
 
480
481
482
...
476
477
478
 
479
480
481
482
0
@@ -476,7 +476,7 @@ class ProjectTest < Test::Unit::TestCase
0
       assert_equal 3, @project.last_builds(5).length
0
     end
0
   end
0
-
0
+
0
   private
0
   
0
   def stub_build(label)
...
105
106
107
108
 
109
110
111
...
105
106
107
 
108
109
110
111
0
@@ -105,7 +105,7 @@ class ProjectsTest < Test::Unit::TestCase
0
 
0
   def test_load_project_with_no_config
0
     in_sandbox do |sandbox|
0
- sandbox.new :file => "myproject/builds-1/__success__"
0
+ sandbox.new :directory => "myproject/builds-1"
0
 
0
       new_project = Projects.load_project(sandbox.root + '/myproject')
0
 

Comments

    No one has commented yet.