Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Prefer JPI plugins over HPI #957

Closed
wants to merge 1 commit into from
Closed
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: 1 addition & 1 deletion manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

# if $source is specified, it overrides any other URL construction
$download_url = $source ? {
undef => "${base_url}${name}.hpi",
undef => "${base_url}${name}.jpi",
default => $source,
}

Expand Down
4 changes: 2 additions & 2 deletions spec/acceptance/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
].freeze

shared_examples 'has_git_plugin' do
describe file("#{PDIR}/git.hpi") do
describe file("#{PDIR}/git.jpi") do
it { is_expected.to be_file }
end
describe file("#{PDIR}/git") do
Expand Down Expand Up @@ -94,7 +94,7 @@ class {'jenkins':
apply(pp, catch_changes: true)

# Find the version of the installed git plugin
git_version = shell("unzip -p #{PDIR}/git.hpi META-INF/MANIFEST.MF | sed 's/Plugin-Version: \\\(.*\\\)/\\1/;tx;d;:x'").stdout.strip
git_version = shell("unzip -p #{PDIR}/git.jpi META-INF/MANIFEST.MF | sed 's/Plugin-Version: \\\(.*\\\)/\\1/;tx;d;:x'").stdout.strip
git_version.should eq('1.0')
end
it_behaves_like 'has_git_plugin'
Expand Down
90 changes: 45 additions & 45 deletions spec/defines/jenkins_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

describe 'without version' do
it do
is_expected.to contain_archive("#{title}.hpi").with(
source: "#{plugin_host}/latest/myplug.hpi",
path: "#{pdir}/#{title}.hpi",
is_expected.to contain_archive("#{title}.jpi").with(
source: "#{plugin_host}/latest/myplug.jpi",
path: "#{pdir}/#{title}.jpi",
cleanup: false,
extract: false
).that_requires("File[#{pdir}]").
that_notifies('Service[jenkins]')
end
it do
is_expected.to contain_file("#{pdir}/#{title}.hpi").with(
is_expected.to contain_file("#{pdir}/#{title}.jpi").with(
owner: 'jenkins',
group: 'jenkins',
mode: '0644'
Expand All @@ -32,29 +32,29 @@
let(:params) { { version: '1.2.3' } }

it do
is_expected.to contain_archive('myplug.hpi').with(
source: "#{plugin_host}/download/plugins/myplug/1.2.3/myplug.hpi"
is_expected.to contain_archive('myplug.jpi').with(
source: "#{plugin_host}/download/plugins/myplug/1.2.3/myplug.jpi"
)
end
it { is_expected.to contain_file("#{pdir}/myplug.hpi") }
it { is_expected.to contain_file("#{pdir}/myplug.jpi") }
end

describe 'with version and in middle of jenkins_plugins fact' do
let(:params) { { version: '1.2.3' } }

let(:facts) { super().merge(jenkins_plugins: 'myplug 1.2.3, fooplug 1.4.5') }

it { is_expected.not_to contain_archive('myplug.hpi') }
it { is_expected.to contain_file("#{pdir}/myplug.hpi") }
it { is_expected.not_to contain_archive('myplug.jpi') }
it { is_expected.to contain_file("#{pdir}/myplug.jpi") }
end

describe 'with version and at end of jenkins_plugins fact' do
let(:params) { { version: '1.2.3' } }

let(:facts) { super().merge(jenkins_plugins: 'fooplug 1.4.5, myplug 1.2.3') }

it { is_expected.not_to contain_archive('myplug.hpi') }
it { is_expected.to contain_file("#{pdir}/myplug.hpi") }
it { is_expected.not_to contain_archive('myplug.jpi') }
it { is_expected.to contain_file("#{pdir}/myplug.jpi") }
end

describe 'with name and version' do
Expand All @@ -63,70 +63,70 @@

let(:facts) { super().merge(jenkins_plugins: 'fooplug 1.4.5, bar-myplug 1.2.3') }

it { is_expected.to contain_archive('myplug.hpi') }
it { is_expected.to contain_file('/var/lib/jenkins/plugins/myplug.hpi') }
it { is_expected.to contain_archive('myplug.jpi') }
it { is_expected.to contain_file('/var/lib/jenkins/plugins/myplug.jpi') }
end

describe 'where name & version are a substring of another plugin' do
let(:params) { { version: '1.2.3' } }

let(:facts) { super().merge(jenkins_plugins: 'fooplug 1.4.5, bar-myplug 1.2.3.4') }

it { is_expected.to contain_archive('myplug.hpi') }
it { is_expected.to contain_file('/var/lib/jenkins/plugins/myplug.hpi') }
it { is_expected.to contain_archive('myplug.jpi') }
it { is_expected.to contain_file('/var/lib/jenkins/plugins/myplug.jpi') }
end

describe 'where version is a substring of the already installed plugin' do
let(:params) { { version: '1.2.3' } }

let(:facts) { super().merge(jenkins_plugins: 'fooplug 1.4.5, myplug 1.2.3.4') }

it { is_expected.to contain_archive('myplug.hpi') }
it { is_expected.to contain_file('/var/lib/jenkins/plugins/myplug.hpi') }
it { is_expected.to contain_archive('myplug.jpi') }
it { is_expected.to contain_file('/var/lib/jenkins/plugins/myplug.jpi') }
end

describe 'and no plugins are installed (should not actually happen)' do
let(:params) { { version: '1.2.3' } }

let(:facts) { super().merge(jenkins_plugins: '') }

it { is_expected.to contain_archive('myplug.hpi') }
it { is_expected.to contain_file('/var/lib/jenkins/plugins/myplug.hpi') }
it { is_expected.to contain_archive('myplug.jpi') }
it { is_expected.to contain_file('/var/lib/jenkins/plugins/myplug.jpi') }
end

describe 'where version contains a + and is already installed' do
let(:params) { { version: '1.2+3.4' } }

let(:facts) { super().merge(jenkins_plugins: 'myplug 1.2+3.4') }

it { is_expected.not_to contain_archive('myplug.hpi') }
it { is_expected.to contain_file('/var/lib/jenkins/plugins/myplug.hpi') }
it { is_expected.not_to contain_archive('myplug.jpi') }
it { is_expected.to contain_file('/var/lib/jenkins/plugins/myplug.jpi') }
end
end # 'with name and version'

describe 'with enabled is false' do
let(:params) { { enabled: false } }

it { is_expected.to contain_archive('myplug.hpi') }
it { is_expected.to contain_file("#{pdir}/myplug.hpi") }
it { is_expected.to contain_archive('myplug.jpi') }
it { is_expected.to contain_file("#{pdir}/myplug.jpi") }
it do
is_expected.to contain_file("#{pdir}/myplug.hpi.disabled").with(
is_expected.to contain_file("#{pdir}/myplug.jpi.disabled").with(
ensure: 'present',
owner: 'jenkins',
group: 'jenkins',
mode: '0644'
).that_requires("Archive[#{title}.hpi]").
).that_requires("Archive[#{title}.jpi]").
that_notifies('Service[jenkins]')
end
end

describe 'with enabled is true' do
let(:params) { { enabled: true } }

it { is_expected.to contain_archive('myplug.hpi') }
it { is_expected.to contain_file("#{pdir}/myplug.hpi") }
it { is_expected.to contain_archive('myplug.jpi') }
it { is_expected.to contain_file("#{pdir}/myplug.jpi") }
it do
is_expected.to contain_file("#{pdir}/myplug.hpi.disabled").with(
is_expected.to contain_file("#{pdir}/myplug.jpi.disabled").with(
ensure: 'absent'
)
end
Expand All @@ -143,7 +143,7 @@ class { jenkins:
end

it do
is_expected.to contain_archive('myplug.hpi').with(
is_expected.to contain_archive('myplug.jpi').with(
proxy_server: 'http://proxy.company.com:8080'
)
end
Expand All @@ -159,16 +159,16 @@ class { jenkins:
end

it do
is_expected.to contain_archive('myplug.hpi').with(
source: 'https://update.jenkins.custom/latest/myplug.hpi'
is_expected.to contain_archive('myplug.jpi').with(
source: 'https://update.jenkins.custom/latest/myplug.jpi'
)
end
end

describe 'with a custom update center' do
shared_examples 'execute the right fetch command' do
it 'retrieves the plugin' do
is_expected.to contain_archive('git.hpi').with(source: expected_url.to_s)
is_expected.to contain_archive('git.jpi').with(source: expected_url.to_s)
end
end

Expand All @@ -179,28 +179,28 @@ class { jenkins:
let(:version) { '1.3.3.7' }
let(:params) { { version: version } }
let(:expected_url) do
"#{plugin_host}/download/plugins/#{title}/#{version}/#{title}.hpi"
"#{plugin_host}/download/plugins/#{title}/#{version}/#{title}.jpi"
end

include_examples 'execute the right fetch command'
end

context 'without a version' do
let(:expected_url) do
"#{plugin_host}/latest/#{title}.hpi"
"#{plugin_host}/latest/#{title}.jpi"
end

include_examples 'execute the right fetch command'
end
end

context 'with a custom update_url' do
let(:update_url) { 'http://rspec' }
let(:update_url) { 'http://rspec.example.com' }

context 'without a version' do
let(:params) { { update_url: update_url } }
let(:expected_url) do
"#{update_url}/latest/#{title}.hpi"
"#{update_url}/latest/#{title}.jpi"
end

include_examples 'execute the right fetch command'
Expand All @@ -210,7 +210,7 @@ class { jenkins:
let(:version) { '1.2.3' }
let(:params) { { update_url: update_url, version: version } }
let(:expected_url) do
"#{update_url}/download/plugins/#{title}/#{version}/#{title}.hpi"
"#{update_url}/download/plugins/#{title}/#{version}/#{title}.jpi"
end

include_examples 'execute the right fetch command'
Expand All @@ -221,14 +221,14 @@ class { jenkins:
describe 'source' do
shared_examples 'should download from $source url' do
it 'downloads from $source url' do
is_expected.to contain_archive('myplug.hpi').with(
source: 'http://e.org/myplug.hpi'
is_expected.to contain_archive('myplug.jpi').with(
source: 'http://e.org/myplug.jpi'
).
that_requires("File[#{pdir}]")
end
end

let(:params) { { source: 'http://e.org/myplug.hpi' } }
let(:params) { { source: 'http://e.org/myplug.jpi' } }

context 'other params at defaults' do
include_examples 'should download from $source url'
Expand All @@ -248,7 +248,7 @@ class { jenkins:

context 'validate_string' do
context 'string' do
let(:params) { { source: 'foo.hpi' } }
let(:params) { { source: 'foo.jpi' } }

it { is_expected.to compile.and_raise_error(%r{source}) }
end
Expand All @@ -269,22 +269,22 @@ class { jenkins:
let(:params) { { pin: true } }

it do
is_expected.to contain_file("#{pdir}/foo.hpi.pinned").with(
is_expected.to contain_file("#{pdir}/foo.jpi.pinned").with(
ensure: 'file',
owner: 'jenkins',
group: 'jenkins'
).
that_requires('Archive[foo.hpi]').
that_requires('Archive[foo.jpi]').
that_notifies('Service[jenkins]')
end
end
context 'with pin => false' do
let(:params) { { pin: false } }

it { is_expected.to contain_file("#{pdir}/foo.hpi.pinned").without_ensure }
it { is_expected.to contain_file("#{pdir}/foo.jpi.pinned").without_ensure }
end
context 'with default pin param' do
it { is_expected.to contain_file("#{pdir}/foo.hpi.pinned").without_ensure }
it { is_expected.to contain_file("#{pdir}/foo.jpi.pinned").without_ensure }
end
end
end # pinned file extension name
Expand Down