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

Commit

Permalink
Added a pull@ preface that will skip the first pass of resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Henrich committed Mar 24, 2015
1 parent b906781 commit c284c7d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
1 change: 1 addition & 0 deletions .ackrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
--ignore-dir=doc
--ignore-dir=out
--ignore-dir=coverage
--sort-files
23 changes: 4 additions & 19 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2014-06-23 17:07:53 -0400 using RuboCop version 0.23.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

#######
# WIP
# WIP These should all go back to defaults at some point
Metrics/CyclomaticComplexity:
Max: 9

Metrics/PerceivedComplexity:
Max: 11

########
# Fix these later
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 27
Metrics/ClassLength:
#Enabled: false
Max: 500
Max: 525

#######
# Finalized settings
Expand All @@ -32,10 +21,6 @@ Metrics/LineLength:
- 'spec/lib/jenkins_pipeline_builder/pull_request_generator_spec.rb'
- 'lib/jenkins_pipeline_builder/extensions/*'

# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 25

Style/Documentation:
Enabled: false

Expand Down
5 changes: 5 additions & 0 deletions lib/jenkins_pipeline_builder/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
module JenkinsPipelineBuilder
class Compiler
def self.resolve_value(value, settings, job_collection)
# pull@ designates that this is a reference to a job that will be generated
# for a pull request, so we want to save the resolution for the second pass
pull_job = value.to_s.match(/{{pull@(.*)}}/)
return pull_job[1] if pull_job

settings = settings.with_indifferent_access
value_s = value.to_s.clone
# First we try to do job name correction
Expand Down
12 changes: 10 additions & 2 deletions lib/jenkins_pipeline_builder/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,27 @@ def pull_request(path, project_name)
load_collection_from_path(path)
cleanup_temp_remote
logger.info "Project: #{projects}"
errors = {}
projects.each do |project|
next unless project[:name] == project_name || project_name.nil?
logger.info "Using Project #{project}"
pull_job = find_pull_request_generator(project)
p_success, p_payload = compile_pull_request_generator(pull_job[:name], project)
next unless p_success
unless p_success
errors[pull_job[:name]] = p_payload
next
end
jobs = filter_pull_request_jobs(pull_job)
pull = JenkinsPipelineBuilder::PullRequestGenerator.new(project, jobs, p_payload)
@job_collection.merge! pull.jobs
success = create_pull_request_jobs(pull)
failed = success unless success
purge_pull_request_jobs(pull)
end
errors.each do |k, v|
logger.error "Encountered errors compiling: #{k}:"
logger.error v
end
!failed
end

Expand Down Expand Up @@ -384,7 +392,7 @@ def process_job_changes(jobs)
next unless j

Utils.hash_merge!(j, job[job_id])
j[:value][:name] = j[:job_name] if j[:job_name]
j[:value][:name] = j[:value][:job_name] if j[:value][:job_name]
end
end

Expand Down

0 comments on commit c284c7d

Please sign in to comment.