Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
fix for branch specifier that is not of String type
Browse files Browse the repository at this point in the history
now just skipping such projects instead of raising exception (JENKINS-24232)
  • Loading branch information
elvanja committed Oct 25, 2014
1 parent b32b58b commit dc12485
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions models/values/project.rb
Expand Up @@ -52,7 +52,11 @@ def get_branch_name_parameter
end
end

raise ConfigurationException.new("only string parameters for branch parameter are supported") if branch_name_param && !branch_name_param.java_kind_of?(StringParameterDefinition)
if branch_name_param && !branch_name_param.java_kind_of?(StringParameterDefinition)
logger.warning("only string parameters for branch parameter are supported")
return nil
end

branch_name_param
end

Expand Down Expand Up @@ -80,7 +84,7 @@ def matches_branch?(branch, exactly = false)
matched_branch = get_branch_name_parameter if !matched_branch && parametrized?

build_chooser = scm.buildChooser
build_chooser && build_chooser.java_kind_of?(InverseBuildChooser) ? !matched_branch : matched_branch
build_chooser && build_chooser.java_kind_of?(InverseBuildChooser) ? matched_branch.nil? : !matched_branch.nil?
end

def git?
Expand Down
6 changes: 4 additions & 2 deletions spec/values/project_spec.rb
Expand Up @@ -106,9 +106,11 @@ module GitlabWebHook
expect(subject.matches?(details_uri, anything)).not_to be
end

it 'raises exception when branch parameter is not of supported type' do
it 'does not match when branch parameter is not of supported type' do
allow(branch_name_parameter).to receive(:java_kind_of?).with(StringParameterDefinition) { false }
expect { subject.matches?(details_uri, anything) }.to raise_exception(ConfigurationException)
expect(logger).to receive(:warning)
expect(logger).to receive(:info)
expect(subject.matches?(details_uri, anything)).not_to be
end

it 'matches when branch parameter found and is of supported type' do
Expand Down

0 comments on commit dc12485

Please sign in to comment.