Skip to content

Commit

Permalink
Move plugin removal to plugins recipe
Browse files Browse the repository at this point in the history
Signed-off-by: Crola1702 <[email protected]>
  • Loading branch information
Crola1702 committed Jan 30, 2025
1 parent 8cdd881 commit ea3bd19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 0 additions & 8 deletions recipes/jenkins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@
node.run_state[:jenkins_password] = chef_user['password']
node.default['jenkins']['executor']['protocol'] = 'http'

# Remove plugins that were required previously but are not now.
# Delete *.jpi files in plugin directory by filtering plugins to remove from a grep command
plugin_remove_filter = node.default['ros_buildfarm']['jenkins']['remove_plugins'].map! {|e| "#{e}.jpi"}.join("|")
execute "ls /var/lib/jenkins/plugins | grep -E \"#{plugin_remove_filter}\" | xargs -r rm" do
# If there are no plugins, then we don't need to remove anythi ng
only_if { ::Dir.exist? '/var/lib/jenkins/plugins/' }
end

# Install plugins required to run ros_buildfarm.
include_recipe '::plugins'

Expand Down
9 changes: 9 additions & 0 deletions recipes/plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@
user "jenkins"
notifies :restart, 'service[jenkins]', :delayed
end

# Remove plugins that were required previously but are not now. By:
# * Listing all plugins (.jpi files) in the plugin directories
# * Delete the plugins (.jpi file) stated in ['jenkins']['remove_plugins']
plugin_remove_filter = node.default['ros_buildfarm']['jenkins']['remove_plugins'].map! {|e| "#{e}.jpi"}.join("|")
execute "ls /var/lib/jenkins/plugins | grep -E \"#{plugin_remove_filter}\" | xargs -r rm" do
# If there are no plugins, then we don't need to remove anything
only_if { ::Dir.exist? '/var/lib/jenkins/plugins/' }
end

0 comments on commit ea3bd19

Please sign in to comment.