<commit_before>#
# Author:: <NAME> <<EMAIL>>
# Cookbook Name:: jenkins-box-for-travis
# Recipe:: ensure-plugins
#
# Description: Install necessary plugins to run the same that can be run on TravisCI
#              The current opscode jenkins recipe failed to install the plugins so this recipe to the rescue.
#
# MIT License (2013)
#
include_recipe 'jenkins'

plugins_to_install = node[:jenkins][:server][:plugins]

# Ensure jenkins user home dir exists
directory node[:jenkins][:server][:home] do
  owner node[:jenkins][:server][:user]
  group node[:jenkins][:server][:group]
  action :create
end

# Fixes possible error:
#   STDOUT: `git` is neither a valid file, URL, nor a plugin artifact name in the update center
#   No update center data is retrieved yet from: http://updates.jenkins-ci.org/update-center.json
directory "#{node[:jenkins][:server][:home]}/updates" do
  owner node[:jenkins][:server][:user]
  group node[:jenkins][:server][:group]
  action :create
end
remote_file "#{node[:jenkins][:server][:home]}/updates/default-temp.json" do
  source 'http://updates.jenkins-ci.org/update-center.json'
  owner node[:jenkins][:server][:user]
  group node[:jenkins][:server][:group]
end
# TODO: This script depends on `sed` which currently no cookbook is available: http://community.opscode.com/cookbooks/sed
execute 'update jenkins update center' do
  # command "wget http://updates.jenkins-ci.org/update-center.json -qO- | sed '1d;$d'  > #{node[:jenkins][:server][:home]}/updates/default.json"
  command "sed '1d;$d' #{node[:jenkins][:server][:home]}/updates/default-temp.json > #{node[:jenkins][:server][:home]}/updates/default.json"
  user node[:jenkins][:server][:user]
  group node[:jenkins][:server][:group]
  creates "#{node[:jenkins][:server][:home]}/updates/default.json"
end

# Finally install all plugins and restart once
jenkins_cli "install-plugin #{plugins_to_install.join(' ')}"
jenkins_cli 'safe-restart'<commit_msg>Avoid timeout on jenkins cli plugin installs by instaling one by one<commit_after>#
# Author:: <NAME> <<EMAIL>>
# Cookbook Name:: jenkins-box-for-travis
# Recipe:: ensure-plugins
#
# Description: Install necessary plugins to run the same that can be run on TravisCI
#              The current opscode jenkins recipe failed to install the plugins so this recipe to the rescue.
#
# MIT License (2013)
#
include_recipe 'jenkins'

plugins_to_install = node[:jenkins][:server][:plugins]

# Ensure jenkins user home dir exists
directory node[:jenkins][:server][:home] do
  owner node[:jenkins][:server][:user]
  group node[:jenkins][:server][:group]
  action :create
end

# Fixes possible error:
#   STDOUT: `git` is neither a valid file, URL, nor a plugin artifact name in the update center
#   No update center data is retrieved yet from: http://updates.jenkins-ci.org/update-center.json
directory "#{node[:jenkins][:server][:home]}/updates" do
  owner node[:jenkins][:server][:user]
  group node[:jenkins][:server][:group]
  action :create
end
remote_file "#{node[:jenkins][:server][:home]}/updates/default-temp.json" do
  source 'http://updates.jenkins-ci.org/update-center.json'
  owner node[:jenkins][:server][:user]
  group node[:jenkins][:server][:group]
end
# TODO: This script depends on `sed` which currently no cookbook is available: http://community.opscode.com/cookbooks/sed
execute 'update jenkins update center' do
  # command "wget http://updates.jenkins-ci.org/update-center.json -qO- | sed '1d;$d'  > #{node[:jenkins][:server][:home]}/updates/default.json"
  command "sed '1d;$d' #{node[:jenkins][:server][:home]}/updates/default-temp.json > #{node[:jenkins][:server][:home]}/updates/default.json"
  user node[:jenkins][:server][:user]
  group node[:jenkins][:server][:group]
  creates "#{node[:jenkins][:server][:home]}/updates/default.json"
end

plugins_to_install.each do |plugin|
  jenkins_cli "install plugin #{plugin}" do
    # timeout 1800 # http://goo.gl/7C5CUc && http://goo.gl/JAEhDm
    # command "install-plugin #{plugins_to_install.join(' ')}"
    command "install-plugin #{plugin}"
  end
end

jenkins_cli 'safe-restart'
{'fraction_non_alphanumeric': 0.15907978463044542, 'fraction_numerical': 0.004405286343612335, 'mean_word_length': 5.487301587301587, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5598155', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1359, 'n_words': 342}