From c7418a761af1ff56abd841e7dd6cf4614535bb91 Mon Sep 17 00:00:00 2001 From: zoojar Date: Thu, 21 Mar 2024 15:31:36 +0000 Subject: [PATCH] Fixes #1090 Stage plugin before deleting existing plugin, remove, then move --- manifests/plugin.pp | 14 ++++++++++---- spec/defines/jenkins_plugin_spec.rb | 13 ++++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 1fb6f7558..a5c852919 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -182,12 +182,12 @@ $checksum_type = undef } - exec { "force ${plugin}-${version}": - command => "/bin/rm -rf ${jenkins::plugin_dir}/${plugin}", + exec { "force staged ${plugin}-${version}": + command => "/bin/rm -rf ${jenkins::plugin_dir}/${plugin}.staged", } -> archive { $plugin: source => $download_url, - path => "${jenkins::plugin_dir}/${plugin}", + path => "${jenkins::plugin_dir}/${plugin}.staged", checksum_verify => $checksum_verify, checksum => $checksum, checksum_type => $checksum_type, @@ -195,7 +195,13 @@ cleanup => false, extract => false, require => $plugindir, - notify => $notify, + } + -> exec { "force ${plugin}-${version}": + command => "/bin/rm -rf ${jenkins::plugin_dir}/${plugin}", + } + -> exec { "stage ${plugin}-${version}": + command => "/bin/mv -f ${jenkins::plugin_dir}/${plugin}.staged ${jenkins::plugin_dir}/${plugin}", + notify => $notify, } $archive_require = Archive[$plugin] } else { diff --git a/spec/defines/jenkins_plugin_spec.rb b/spec/defines/jenkins_plugin_spec.rb index 862aae0c2..112ce1e28 100644 --- a/spec/defines/jenkins_plugin_spec.rb +++ b/spec/defines/jenkins_plugin_spec.rb @@ -15,10 +15,20 @@ it do is_expected.to contain_archive("#{title}.hpi").with( source: "#{plugin_host}/latest/myplug.hpi", - path: "#{pdir}/#{title}.hpi", + path: "#{pdir}/#{title}.hpi.staged", cleanup: false, extract: false ).that_requires("File[#{pdir}]"). + that_comes_before("Exec[force #{title}.hpi-]") + end + + it do + is_expected.to contain_("Exec[force #{title}.hpi-]"). + that_comes_before("Exec[stage #{title}.hpi-]") + end + + it do + is_expected.to contain_("Exec[stage #{title}.hpi-]"). that_notifies('Service[jenkins]') end @@ -29,6 +39,7 @@ mode: '0644' ).that_comes_before('Service[jenkins]') end + end describe 'with version' do