diff --git a/Gemfile b/Gemfile index d118d44..362ab92 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem 'nokogiri' gem 'sqlite3-ruby' gem 'resque' gem 'grit' -gem 'RedCloth', '4.2.3' +gem 'RedCloth', '4.2.5' gem 'aasm' gem 'broach' gem 'mongrel', '1.2.0.pre2' diff --git a/Gemfile.lock b/Gemfile.lock index 7206b69..e958f07 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GEM remote: http://rubygems.org/ specs: - RedCloth (4.2.3) + RedCloth (4.2.5) aasm (2.2.0) abstract (1.0.0) actionmailer (3.0.1) @@ -159,7 +159,7 @@ PLATFORMS ruby DEPENDENCIES - RedCloth (= 4.2.3) + RedCloth (= 4.2.5) aasm annotate-models broach diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index 3dccad8..5895d99 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -22,6 +22,9 @@ <%= f.label :script, "Script" %> <%= f.text_area :script %>
++
<%= f.check_box :campfire, :class => 'checkbox' %> <%= f.label :campfire, "Campfire Notifications", :class => 'checkbox' %> @@ -40,6 +43,24 @@
<%= f.check_box :ssl, :class => 'checkbox' %> - <%= f.label :ssl, "SSL?", :class => 'checkbox' %> + <%= f.label :ssl, "Campfire requires SSL?", :class => 'checkbox' %> +
++
+ <%= f.check_box :irc, :class => 'checkbox' %> + <%= f.label :irc, "IRC Notifications", :class => 'checkbox' %>
- ++ <%= f.label :channel, "Channel (example, #projectname)" %> + <%= f.text_field :channel %> +
++ <%= f.label :ircserver, "IRC Server" %> + <%= f.text_field :ircserver %> +
++ <%= f.label :ircnick, "IRC Nick (example, magnum_ci)" %> + <%= f.text_field :ircnick %> +
\ No newline at end of file diff --git a/db/migrate/20120501155429_add_irc_to_projects.rb b/db/migrate/20120501155429_add_irc_to_projects.rb new file mode 100644 index 0000000..26c4791 --- /dev/null +++ b/db/migrate/20120501155429_add_irc_to_projects.rb @@ -0,0 +1,15 @@ +class AddIrcToProjects < ActiveRecord::Migration + def self.up + add_column :projects, :irc, :boolean + add_column :projects, :channel, :string + add_column :projects, :ircserver, :string + add_column :projects, :ircnick, :string + end + + def self.down + remove_column :projects, :irc + remove_column :projects, :channel + remove_column :projects, :server + remove_column :projects, :ircnick + end +end diff --git a/lib/run_build.rb b/lib/run_build.rb index 5d7fc6d..353a87f 100644 --- a/lib/run_build.rb +++ b/lib/run_build.rb @@ -1,3 +1,30 @@ +require "socket" + +# The irc class, which talks to the server and holds the main event loop +class IRC + def initialize(server, port, nick, channel) + @server = server + @port = port + @nick = nick + @channel = channel + @irc = ::TCPSocket.open(@server, @port) + send "USER blah blah blah :blah blah" + send "NICK #{@nick}" + send "JOIN #{@channel}" + puts "(Tried to) Connected to IRC server" + end + def send(s) + # Send a message to the irc server and print it to the screen + puts "--> #{s}" + @irc.send "#{s}\n", 0 + end + def destroy + send "server disconnect" + @irc.close + puts "Disconnected from IRC server" + end +end + class RunBuild @queue = :build class << self @@ -24,8 +51,15 @@ def build def notify if @build.project.campfire Broach.settings = @build.project.campfire_settings - Broach.speak(@build.project.room, "#{@build.project.name.titleize} commit #{@build.name} pushed by #{@build.committer} #{@build.pass_fail} [ #{APP_CONFIG[:site][:address]}/#{@build.project.name}/builds/#{@build.id} ]") + Broach.speak(@build.project.room, "#{@build.project.name.titleize} commit #{@build.name} pushed by #{@build.committer} #{@build.pass_fail} [ #{APP_CONFIG[:site][:address]}/#{@build.project.name}/builds/#{@build.id} ]") + end + + if @build.project.irc + @irc = IRC.new(@build.project.ircserver, '6667', @build.project.ircnick, @build.project.channel) + sleep 4 + @irc.send("privmsg #{@build.project.channel} :#{@build.project.name.titleize} commit #{@build.name} pushed by #{@build.committer} #{@build.pass_fail} \[ #{APP_CONFIG[:site][:address]}/#{@build.project.name}/builds/#{@build.id} \]\n") + @irc.destroy end - end + end end end diff --git a/lib/tasks/workers.rake b/lib/tasks/workers.rake index cf0ea44..11c0432 100644 --- a/lib/tasks/workers.rake +++ b/lib/tasks/workers.rake @@ -60,9 +60,9 @@ namespace :workers do desc "Start all Magnum CI queues" task :magnum_ci do - `nohup rake workers:start COUNT=1 QUEUE=build > log/workers.log 2>&1 &` - `nohup rake workers:start COUNT=2 QUEUE=clone > log/workers.log 2>&1 &` - `nohup rake workers:start COUNT=2 QUEUE=delete > log/workers.log 2>&1 &` + `nohup rake workers:start COUNT=1 VVERBOSE=1 QUEUE=build --trace > log/workers.log 2>&1 &` + `nohup rake workers:start COUNT=2 VVERBOSE=1 QUEUE=clone --trace > log/workers.log 2>&1 &` + `nohup rake workers:start COUNT=2 VVERBOSE=1 QUEUE=delete --trace > log/workers.log 2>&1 &` end desc "Run and manage group of Resque workers with some default options"