Permalink
Browse files

Adding an action works, but it can't be deserialized.

  • Loading branch information...
1 parent 02320a9 commit 9f75bf4099ad0dfdc087ff896659ab5cad30db21 @rsutphin rsutphin committed Mar 16, 2012
Showing with 56 additions and 2 deletions.
  1. +33 −0 models/bundled_gems.rb
  2. +4 −0 models/lockfile_recorder.rb
  3. +19 −2 spec/models/lockfile_recorder_spec.rb
@@ -0,0 +1,33 @@
+class BundledGems
+ include Java.hudson.model.Action
+ include Jenkins::Model
+
+ display_name 'Bundled Gems'
+
+ def url_name
+ 'bundledGems'
+ end
+
+ def icon_file_name
+ 'fingerprint.png'
+ end
+
+ attr_accessor :archived_lockfile
+
+ def initialize(archived_lockfile)
+ super()
+
+ @archived_lockfile = archived_lockfile.to_s
+ end
+end
+
+# TODO: this isn't being used, I don't think (at least, there's
+# behavior difference whether it is present or not). It was added as a
+# stab at fixing the serialization problem. I'm leaving it here as a
+# reminder until I figure out an actual solution.
+class BundledGemsProxy
+ include Jenkins::Plugin::Proxy
+ # include Jenkins::Plugin::Proxies::Action
+
+ proxy_for BundledGems
+end
@@ -8,8 +8,11 @@ def perform(build, launcher, listener)
archive_target = archive_dir(build).child('Gemfile.lock')
listener.info("Recording bundle to #{archive_target}.")
lockfile.copyTo(archive_target)
+
+ build.native.add_action(BundledGems.new(archive_target))
else
listener.error("No bundle lock present to record. Was expecting #{lockfile}.")
+ build.native.result = Java.hudson.model.Result::FAILURE
end
end
@@ -22,4 +25,5 @@ def built_lockfile(build)
# TODO: allow this to be configured
build.native.workspace.child('Gemfile.lock')
end
+ private :built_lockfile
end
@@ -1,6 +1,7 @@
require 'spec_helper'
require 'models/lockfile_recorder'
+require 'models/bundled_gems'
describe LockfileRecorder do
let(:native_build) { double('java build') }
@@ -15,7 +16,9 @@
before do
native_build.stub!(:workspace).and_return(file_path workspace)
native_build.stub!(:artifacts_dir).and_return(java_file artifacts_dir)
+ native_build.stub!(:result=).and_return(java_file artifacts_dir)
native_build.stub!(:buildEnvironments).and_return(java.util.ArrayList.new)
+ native_build.stub!(:add_action)
[:debug, :info, :warn, :error, :fatal, :unknown].each { |level| listener.stub!(level) }
end
@@ -34,19 +37,27 @@ def perform
].join("\n")
}
+ let(:expected_archive_file) { (artifacts_dir + 'bundle-recorder' + 'Gemfile.lock') }
+
before do
(workspace + 'Gemfile.lock').open('w') { |f| f.write source }
end
it 'copies Gemfile.lock to a subdirectory of the artifacts directory' do
perform
- (artifacts_dir + 'bundle-recorder' + 'Gemfile.lock').read.should == source
+ expected_archive_file.read.should == source
end
it 'notes what it is doing in the log' do
listener.should_receive(:info).
- with("Recording bundle to #{artifacts_dir + 'bundle-recorder/Gemfile.lock'}.")
+ with("Recording bundle to #{expected_archive_file}.")
+
+ perform
+ end
+
+ it 'registers the action' do
+ native_build.should_receive(:add_action)
perform
end
@@ -59,5 +70,11 @@ def perform
perform
end
+
+ it 'stops the build' do
+ native_build.should_receive(:result=).with(Java.hudson.model.Result::FAILURE)
+
+ perform
+ end
end
end

0 comments on commit 9f75bf4

Please sign in to comment.