Skip to content

Commit

Permalink
Merge pull request #34 from Workday/FixJenkinsPlugin
Browse files Browse the repository at this point in the history
JenkinsPlugin not saving project level settings
  • Loading branch information
ScottBishop authored Mar 12, 2019
2 parents c064e0d + 92b1f76 commit 48283ec
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
17 changes: 9 additions & 8 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ def destroy

def save_plugin_settings(settings, enabled_plugins)
return if settings.blank?
settings.each do |setting|
settings_hash = settings[setting]
settings_hash[:enabled] = if enabled_plugins.blank?
false
else
enabled_plugins[setting] == 'true'
end
@project.plugin_settings[setting] = settings_hash
PluginManager.instance.for_project(@project).plugins_hash.each do |plugin|
plugin_key = plugin.first
plugin_settings_hash = settings[plugin_key] || {}
plugin_settings_hash[:enabled] = if enabled_plugins.blank?
false
else
enabled_plugins[plugin_key] == 'true'
end
@project.plugin_settings[plugin_key] = plugin_settings_hash
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/plugins/bamboo_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def comment_on_build(build)
response
end

# Add bammboo url from project plugin settings
# Add bamboo url from project plugin settings
# Params:
# - project: project to look for plugin settings
def get_base_bamboo_url(project)
Expand Down
Binary file modified secrets.yml.enc
Binary file not shown.
5 changes: 5 additions & 0 deletions test/plugins/jenkins_plugin_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def setup
@build.save

@jenkins_plugin = JenkinsPlugin.new(@unique_id)
@project_settings_hash = @build.project.plugin_settings
end

test 'verify hook calls update description' do
Expand All @@ -23,4 +24,8 @@ def setup
plugin_manager = PluginManager.instance.for_project(@build.project)
assert_not_nil(plugin_manager.plugins_hash[@unique_id])
end

test 'jenkins plugin disabled' do
assert_equal(false, @project_settings_hash[@jenkins_plugin.unique_id][:enabled])
end
end

0 comments on commit 48283ec

Please sign in to comment.