Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

set user on exec resources in jenkins::plugin define #289

Merged
merged 1 commit into from
May 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
path => ['/usr/bin', '/usr/sbin', '/bin'],
onlyif => "test -f ${plugin_dir}/${name}.jpi -a ! -f ${plugin_dir}/${name}.jpi.pinned",
before => Exec["download-${name}"],
user => $username,
}

# if $source is specified, it overrides any other URL construction
Expand All @@ -152,6 +153,7 @@
cwd => $plugin_dir,
require => [File[$plugin_dir], Package['wget']],
path => ['/usr/bin', '/usr/sbin', '/bin'],
user => $username,
}

file { "${plugin_dir}/${plugin}" :
Expand Down
32 changes: 23 additions & 9 deletions spec/defines/jenkins_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@


describe 'without version' do
it { should contain_exec('download-myplug').with(
:command => 'rm -rf myplug myplug.hpi myplug.jpi && wget --no-check-certificate http://updates.jenkins-ci.org/latest/myplug.hpi',
:environment => nil
)}
it do
should contain_exec('download-myplug').with(
:command => 'rm -rf myplug myplug.hpi myplug.jpi && wget --no-check-certificate http://updates.jenkins-ci.org/latest/myplug.hpi',
:user => 'jenkins',
:environment => nil
)
end
it { should contain_file('/var/lib/jenkins/plugins/myplug.hpi')}
end

describe 'with version' do
let(:params) { { :version => '1.2.3' } }

it { should contain_exec('download-myplug').with(
:command => 'rm -rf myplug myplug.hpi myplug.jpi && wget --no-check-certificate http://updates.jenkins-ci.org/download/plugins/myplug/1.2.3/myplug.hpi',
:environment => nil
) }
it do
should contain_exec('download-myplug').with(
:command => 'rm -rf myplug myplug.hpi myplug.jpi && wget --no-check-certificate http://updates.jenkins-ci.org/download/plugins/myplug/1.2.3/myplug.hpi',
:user => 'jenkins',
:environment => nil
)
end
it { should contain_file('/var/lib/jenkins/plugins/myplug.hpi')}
end

Expand Down Expand Up @@ -96,7 +102,14 @@
'include jenkins'
]}

it { should contain_exec('download-myplug').with(:environment => ["http_proxy=proxy.company.com:8080", "https_proxy=proxy.company.com:8080"]) }
it do
should contain_exec('download-myplug').with(
:environment => [
"http_proxy=proxy.company.com:8080",
"https_proxy=proxy.company.com:8080",
]
)
end
end

describe 'with a custom update center' do
Expand Down Expand Up @@ -168,6 +181,7 @@
it 'should download from $source url' do
should contain_exec('download-myplug').with(
:command => 'rm -rf myplug myplug.hpi myplug.jpi && wget --no-check-certificate http://e.org/myplug.hpi',
:user => 'jenkins',
:cwd => '/var/lib/jenkins/plugins',
:environment => nil,
:path => ['/usr/bin', '/usr/sbin', '/bin'],
Expand Down