Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
Version bump 0.14.0 and rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
crimsonknave committed Feb 5, 2016
1 parent 592a34a commit 0685bbb
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.1.4
ruby-2.2.4
4 changes: 2 additions & 2 deletions .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ SimpleCov.profiles.define 'spec' do
add_group 'jenkins_pipeline_builder', '/lib/'
add_filter 'spec'
coverage_dir 'out/coverage'
formatter SimpleCov::Formatter::MultiFormatter.new([
formatter SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::Console,
SimpleCov::Formatter::RcovFormatter,
])
]
end

class SimpleCov::Formatter::Console
Expand Down
2 changes: 1 addition & 1 deletion lib/jenkins_pipeline_builder/cli/pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def dump(job_name)
desc 'bootstrap Path', 'Generates pipeline from folder or a file'
def bootstrap(path, project_name = nil)
failed = Helper.setup(parent_options).bootstrap(path, project_name)
fail 'Encountered error during run' unless failed.empty?
raise 'Encountered error during run' unless failed.empty?
end

desc 'pull_request Path', 'Generates jenkins jobs based on a git pull request.'
Expand Down
12 changes: 6 additions & 6 deletions lib/jenkins_pipeline_builder/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def handle_enable(item, settings)
enabled_switch = resolve_value(item[:enabled], settings)
return {} if enabled_switch == 'false'
if enabled_switch != 'true'
fail "Invalid value for #{item[:enabled]}: #{enabled_switch}"
raise "Invalid value for #{item[:enabled]}: #{enabled_switch}"
end
if item[:parameters].is_a? Hash
item = item.merge item[:parameters]
Expand Down Expand Up @@ -106,18 +106,18 @@ def compile_array(array, settings)
end

def compile_array_item(item, settings, array)
fail "Found a nil value when processing following array:\n #{array.inspect}" if item.nil?
raise "Found a nil value when processing following array:\n #{array.inspect}" if item.nil?
payload = compile(item, settings)
fail "Failed to resolve:\n===>item #{item}\n\n===>of list: #{array.inspect}" if payload.nil?
raise "Failed to resolve:\n===>item #{item}\n\n===>of list: #{array.inspect}" if payload.nil?
payload
end

def compile_item(key, value, settings)
if value.nil?
fail "key: #{key} has a nil value, this is often a yaml syntax error. Skipping children and siblings"
raise "key: #{key} has a nil value, this is often a yaml syntax error. Skipping children and siblings"
end
payload = compile(value, settings)
fail "Failed to resolve:\n===>key: #{key}\n\n===>value: #{value} payload" if payload.nil?
raise "Failed to resolve:\n===>key: #{key}\n\n===>value: #{value} payload" if payload.nil?
payload
end

Expand Down Expand Up @@ -152,7 +152,7 @@ def resolve_value(value, settings)
vars = value_s.scan(/{{([^{}@]+)}}/).flatten
vars.select! do |var|
var_val = settings[var]
fail "Could not find defined substitution variable: #{var}" if var_val.nil?
raise "Could not find defined substitution variable: #{var}" if var_val.nil?
value_s.gsub!("{{#{var}}}", var_val.to_s)
var_val.nil?
end
Expand Down
8 changes: 4 additions & 4 deletions lib/jenkins_pipeline_builder/extension_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def installed_version
return @version if @version
reg = JenkinsPipelineBuilder.registry
version = reg.versions[settings[:plugin_id]]
fail "Plugin #{settings[:name]} is not installed (plugin_id: #{settings[:plugin_id]})" if version.nil?
raise "Plugin #{settings[:name]} is not installed (plugin_id: #{settings[:plugin_id]})" if version.nil?
self.installed_version = version
@version
end
Expand All @@ -66,7 +66,7 @@ def extension
extension = versions[highest_allowed_version]

unless extension
fail "Can't find version of #{name} lte #{installed_version}, available versions: #{versions.keys.map(&:to_s)}"
raise "Can't find version of #{name} lte #{installed_version}, available versions: #{versions.keys.map(&:to_s)}"
end
extension
end
Expand All @@ -81,7 +81,7 @@ def merge(other_set)
mismatch.each do |error|
puts error
end
fail 'Values did not match, cannot merge extension sets' if mismatch.any?
raise 'Values did not match, cannot merge extension sets' if mismatch.any?

self.extensions = versions.merge(other_set.versions).values
end
Expand All @@ -100,7 +100,7 @@ def xml(path: false, version: '0', &block)
deprecation_warning(settings[:name], 'xml')
end
unless block
fail "no block found for version #{version}" unless blocks.key version
raise "no block found for version #{version}" unless blocks.key version
return blocks[version][:block]
end
store_xml version, block, path
Expand Down
4 changes: 2 additions & 2 deletions lib/jenkins_pipeline_builder/extensions/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@
xml do |params|
send('hudson.plugins.groovy.SystemGroovy', 'plugin' => '[email protected]') do
if params.key?(:script) && params.key?(:file)
fail 'Configuration invalid. Both \'script\' and \'file\' keys can not be specified'
raise 'Configuration invalid. Both \'script\' and \'file\' keys can not be specified'
end
unless params.key?(:script) || params.key?(:file)
fail 'Configuration invalid. At least one of \'script\' and \'file\' keys must be specified'
raise 'Configuration invalid. At least one of \'script\' and \'file\' keys must be specified'
end

scriptSource('class' => 'hudson.plugins.groovy.StringScriptSource') do
Expand Down
4 changes: 2 additions & 2 deletions lib/jenkins_pipeline_builder/extensions/job_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
extensions do
if params[:changelog_to_branch]
opts = params[:changelog_to_branch]
fail 'remote and branch are required for changelog_to_branch' unless opts[:remote] && opts[:branch]
raise 'remote and branch are required for changelog_to_branch' unless opts[:remote] && opts[:branch]
send('hudson.plugins.git.extensions.impl.ChangelogToBranch') do
options do
compareRemote opts[:remote]
Expand Down Expand Up @@ -215,7 +215,7 @@
announced false

xml path: '//properties' do |params|
fail 'No HipChat room specified' unless params[:room]
raise 'No HipChat room specified' unless params[:room]

send('jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty') do
room params[:room]
Expand Down
6 changes: 3 additions & 3 deletions lib/jenkins_pipeline_builder/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def dump(job_name)

def resolve_job_by_name(name, settings = {})
job = job_collection.get_item(name)
fail "Failed to locate job by name '#{name}'" if job.nil?
raise "Failed to locate job by name '#{name}'" if job.nil?
job_value = job[:value]
logger.debug "Compiling job #{name}"
compiler = JenkinsPipelineBuilder::Compiler.new self
Expand Down Expand Up @@ -220,14 +220,14 @@ def create_jobs_and_views(project)

def publish_project(project_name)
project = job_collection.projects.find { |p| p[:name] == project_name }
create_jobs_and_views(project || fail("Project #{project_name} not found!"))
create_jobs_and_views(project || raise("Project #{project_name} not found!"))
end

def publish_jobs(jobs, errors = {})
jobs.each do |i|
logger.info "Processing #{i}"
job = i[:result]
fail "Result is empty for #{i}" if job.nil?
raise "Result is empty for #{i}" if job.nil?
job = Job.new job
success, payload = job.create_or_update
errors[job.name] = payload unless success
Expand Down
4 changes: 2 additions & 2 deletions lib/jenkins_pipeline_builder/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create_or_update
end

def to_xml
fail 'Job name is not specified' unless name
raise 'Job name is not specified' unless name

logger.info "Creating Yaml Job #{job}"
job[:job_type] = 'free_style' unless job[:job_type]
Expand Down Expand Up @@ -112,7 +112,7 @@ def setup_freestyle_base(params)
# I'm pretty unclear what these templates are...
if params.key?(:template)
template_name = params[:template]
fail "Job template '#{template_name}' can't be resolved." unless @job_templates.key?(template_name)
raise "Job template '#{template_name}' can't be resolved." unless @job_templates.key?(template_name)
params.delete(:template)
template = @job_templates[template_name]
puts "Template found: #{template}"
Expand Down
2 changes: 1 addition & 1 deletion lib/jenkins_pipeline_builder/job_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def process_collection!(name, key, value, remote)
existing_remote = collection[name.to_s][:remote]
# skip if the existing item is local and the new item is remote
return if remote && !existing_remote
fail "Duplicate item with name '#{name}' was detected." unless existing_remote && !remote
raise "Duplicate item with name '#{name}' was detected." unless existing_remote && !remote
# override if the existing item is remote and the new is local
logger.info "Duplicate item with name '#{name}' was detected from the remote folder."
end
Expand Down
4 changes: 2 additions & 2 deletions lib/jenkins_pipeline_builder/module_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def traverse_registry(registry, params, n_xml, strict = false)
params.each do |key, value|
next unless registry.is_a? Hash
unless registry.key? key
fail "!!!! could not find key #{key} !!!!" if strict
raise "!!!! could not find key #{key} !!!!" if strict
next
end
reg_value = registry[key]
Expand All @@ -115,7 +115,7 @@ def execute_registry_value(reg_value, value, n_xml)
def execute_extension(ext, value, n_xml)
logger.debug "Using #{ext.type} #{ext.name} version #{ext.min_version}"
success = ext.execute value, n_xml
fail 'Encountered errors compiling the xml' unless success
raise 'Encountered errors compiling the xml' unless success
end
end
end
4 changes: 2 additions & 2 deletions lib/jenkins_pipeline_builder/pull_request_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class NotFound < StandardError; end
attr_accessor :open_prs, :application_name

def initialize(defaults = {})
@application_name = defaults[:application_name] || fail('Please set "application_name" in your project!')
@application_name = defaults[:application_name] || raise('Please set "application_name" in your project!')
@open_prs = active_prs defaults[:github_site], defaults[:git_org], defaults[:git_repo_name]
end

Expand Down Expand Up @@ -57,7 +57,7 @@ def override(job, pr)
end

def active_prs(git_url, git_org, git_repo)
(git_url && git_org && git_repo) || fail('Please set github_site, git_org and git_repo_name in your project.')
(git_url && git_org && git_repo) || raise('Please set github_site, git_org and git_repo_name in your project.')
# Build the Git URL
url = "#{git_url}/api/v3/repos/#{git_org}/#{git_repo}/pulls"
# Download the JSON Data from the API
Expand Down
2 changes: 1 addition & 1 deletion lib/jenkins_pipeline_builder/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
#

module JenkinsPipelineBuilder
VERSION = '0.13.4'.freeze
VERSION = '0.14.0'.freeze
end
4 changes: 2 additions & 2 deletions lib/jenkins_pipeline_builder/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def generate(path)
#
def create(params)
# Name is a required parameter. Raise an error if not specified
fail ArgumentError, 'Name is required for creating view' unless params.is_a?(Hash) && params[:name]
raise ArgumentError, 'Name is required for creating view' unless params.is_a?(Hash) && params[:name]
clean_up_views(params) unless JenkinsPipelineBuilder.debug
params[:type] ||= 'listview'
create_base_view(params[:name], params[:type], params[:parent_view])
Expand Down Expand Up @@ -136,7 +136,7 @@ def get_mode(type)
'dashboardView' => 'hudson.plugins.view.dashboard.Dashboard',
'multijobView' => 'com.tikal.jenkins.plugins.multijob.views.MultiJobView'
}
fail "Type #{type} is not supported by Jenkins." unless types.keys.include? type
raise "Type #{type} is not supported by Jenkins." unless types.keys.include? type
types[type]
end

Expand Down
12 changes: 6 additions & 6 deletions spec/lib/jenkins_pipeline_builder/module_registry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,23 @@ class AfterException < StandardError
end

it 'calls the xml block when executing the item' do
@ext.xml -> (_) { fail XmlException, 'foo' }
@ext.xml -> (_) { raise XmlException, 'foo' }

expect do
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
end.to raise_error XmlException
end

it 'calls the before block' do
@ext.before -> (_) { fail BeforeException, 'foo' }
@ext.before -> (_) { raise BeforeException, 'foo' }

expect do
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
end.to raise_error BeforeException
end

it 'calls the after block' do
@ext.after -> (_) { fail AfterException, 'foo' }
@ext.after -> (_) { raise AfterException, 'foo' }

expect do
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
Expand All @@ -132,7 +132,7 @@ class AfterException < StandardError
plugin_id 'unorderedTest'

before do
fail BeforeException, 'foo'
raise BeforeException, 'foo'
end

xml do
Expand All @@ -154,7 +154,7 @@ class AfterException < StandardError
plugin_id 'unorderedTest'

after do
fail AfterException, 'foo'
raise AfterException, 'foo'
end

xml do
Expand All @@ -176,7 +176,7 @@ class AfterException < StandardError
plugin_id 'unorderedTest'

xml do
fail XmlException, 'foo'
raise XmlException, 'foo'
end

after do
Expand Down

0 comments on commit 0685bbb

Please sign in to comment.