Skip to content

Commit

Permalink
Correct the relationship when managing the pinned file for a plugin
Browse files Browse the repository at this point in the history
The reason this wasn't working before was largely due to the `onlyif` statement
in the exec resource, wihch ends up requiring puppet to run twice to get the
pinned file to work properly

Fixes voxpupuli#380
  • Loading branch information
R. Tyler Croy committed Oct 9, 2015
1 parent e13a7b4 commit 78e83d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@
exec { "create-pinnedfile-${name}" :
command => "touch ${plugin_dir}/${name}.jpi.pinned",
cwd => $plugin_dir,
require => File[$plugin_dir],
require => [
File[$plugin_dir],
Archive::Download[$plugin],
],
path => ['/usr/bin', '/usr/sbin', '/bin'],
onlyif => "test -f ${plugin_dir}/${name}.jpi -a ! -f ${plugin_dir}/${name}.jpi.pinned",
before => Archive::Download[$plugin],
user => $username,
}

Expand Down
9 changes: 8 additions & 1 deletion spec/defines/jenkins_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
it { should contain_group('jenkins') }
it { should contain_user('jenkins').with('home' => '/var/lib/jenkins') }

context 'the pinned file resource' do
it do
should contain_exec("create-pinnedfile-#{title}")
.that_requires("Archive::Download[#{title}.hpi]")
end
end

context 'with my plugin parent directory already defined' do
let(:pre_condition) do
[
Expand All @@ -22,7 +29,6 @@
include_examples 'manages plugins dirs'
end


describe 'without version' do
it do
should contain_archive__download('myplug.hpi').with(
Expand All @@ -31,6 +37,7 @@
)
end
it { should contain_file('/var/lib/jenkins/plugins/myplug.hpi')}

end

describe 'with version' do
Expand Down

0 comments on commit 78e83d1

Please sign in to comment.