From c284c7d52034a8c841735a6ba776492891e84410 Mon Sep 17 00:00:00 2001 From: Joseph Henrich Date: Mon, 23 Mar 2015 20:15:41 -0400 Subject: [PATCH] Added a pull@ preface that will skip the first pass of resolution --- .ackrc | 1 + .rubocop.yml | 23 ++++------------------- lib/jenkins_pipeline_builder/compiler.rb | 5 +++++ lib/jenkins_pipeline_builder/generator.rb | 12 ++++++++++-- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.ackrc b/.ackrc index e7dc778..993410f 100644 --- a/.ackrc +++ b/.ackrc @@ -2,3 +2,4 @@ --ignore-dir=doc --ignore-dir=out --ignore-dir=coverage +--sort-files diff --git a/.rubocop.yml b/.rubocop.yml index 01e34c2..c6a9f06 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -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 @@ -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 diff --git a/lib/jenkins_pipeline_builder/compiler.rb b/lib/jenkins_pipeline_builder/compiler.rb index c8b6b0a..f2c8e1f 100644 --- a/lib/jenkins_pipeline_builder/compiler.rb +++ b/lib/jenkins_pipeline_builder/compiler.rb @@ -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 diff --git a/lib/jenkins_pipeline_builder/generator.rb b/lib/jenkins_pipeline_builder/generator.rb index 604fe60..fc38d70 100644 --- a/lib/jenkins_pipeline_builder/generator.rb +++ b/lib/jenkins_pipeline_builder/generator.rb @@ -90,12 +90,16 @@ 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 @@ -103,6 +107,10 @@ def pull_request(path, project_name) 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 @@ -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