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

Commit

Permalink
CD-6084 -> Create dockerfile (#141)
Browse files Browse the repository at this point in the history
authored-by: Anthony Cicchetti <[email protected]>
  • Loading branch information
anthonycicc authored May 18, 2020
1 parent 570e1ca commit dc7162c
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 27 deletions.
22 changes: 19 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Metrics/ClassLength:
#######
# Finalized settings

Metrics/LineLength:
Layout/LineLength:
Max: 120
Exclude:
- 'spec/lib/jenkins_pipeline_builder/compiler_spec.rb'
Expand All @@ -32,7 +32,7 @@ Style/Next:
- 'lib/jenkins_pipeline_builder/extensions/**/*'

# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/VariableName:
Naming/VariableName:
Exclude:
- 'lib/jenkins_pipeline_builder/extensions/**/*'

Expand All @@ -43,4 +43,20 @@ Style/FrozenStringLiteralComment:
Enabled: false

Style/SafeNavigation:
Enabled: false
Enabled: false

Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true

Style/HashEachMethods:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM centos:centos7

ENV RUBY_DIR /ruby
ENV RUBY_VERSION 2.3.3
ENV RUBY_INSTALL $RUBY_DIR/$RUBY_VERSION
ENV BUNDLER_VERSION 1.13.3

RUN yum update -y && \
yum install -y make gcc-c++ which wget tar git mysql-devel \
gcc patch readline-devel zlib-devel \
libyaml-devel libffi-devel openssl-devel \
gdbm-devel ncurses-devel libxml-devel bzip2 libxml2-devel

RUN cd /usr/src && \
git clone https://github.com/rbenv/ruby-build.git && \
./ruby-build/install.sh && \
mkdir -p $RUBY_INSTALL && \
/usr/local/bin/ruby-build $RUBY_VERSION $RUBY_INSTALL && \
$RUBY_INSTALL/bin/gem install bundler -v $BUNDLER_VERSION && \
rm -rf /usr/src/ruby-build

ENV PATH $RUBY_INSTALL/bin:$PATH

WORKDIR /src

RUN gem install jenkins_pipeline_builder

RUN mkdir -p /srv
WORKDIR /srv
ENTRYPOINT ["/bin/bash", "-l" ]
10 changes: 4 additions & 6 deletions jenkins_pipeline_builder.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ automating Job & Pipeline creation from the YAML files checked-in with your appl
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] = 'true'

spec.add_dependency 'activesupport', '~> 4.2.6'
spec.add_dependency 'jenkins_api_client', '~> 1.0.0'
spec.add_dependency 'minitar'
Expand All @@ -28,17 +26,17 @@ automating Job & Pipeline creation from the YAML files checked-in with your appl
spec.add_dependency 'thor', '>= 0.18.0'

spec.add_development_dependency 'bump'
spec.add_development_dependency 'byebug'
spec.add_development_dependency 'equivalent-xml'
spec.add_development_dependency 'byebug', '= 11.0.1' # last version with compatibility with ruby 2.3.x
spec.add_development_dependency 'equivalent-xml', '= 0.6.0' # last version with compatibility with ruby 2.3.x
spec.add_development_dependency 'gem-release'
spec.add_development_dependency 'json'
spec.add_development_dependency 'kwalify'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rspec_junit_formatter'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'rubocop', '= 0.81' # last version with compatibility with ruby 2.3.x
spec.add_development_dependency 'simplecov', '= 0.17.1' # last version with compatibility with ruby 2.3.x
spec.add_development_dependency 'simplecov-rcov'
spec.add_development_dependency 'webmock', '~> 1.0'
spec.add_development_dependency 'yard'
Expand Down
2 changes: 1 addition & 1 deletion lib/jenkins_pipeline_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def registry
require 'jenkins_pipeline_builder/extension_dsl'
require 'jenkins_pipeline_builder/extension_set'
require 'jenkins_pipeline_builder/extensions/helpers/extension_helper'
Dir[File.join(File.dirname(__FILE__), 'jenkins_pipeline_builder/extensions/helpers/**/*.rb')].each do |file|
Dir[File.join(File.dirname(__FILE__), 'jenkins_pipeline_builder/extensions/helpers/**/*.rb')].sort.each do |file|
require file
end

Expand Down
2 changes: 1 addition & 1 deletion lib/jenkins_pipeline_builder/cli/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
module JenkinsPipelineBuilder
module CLI
class List < Thor
JenkinsPipelineBuilder.registry.entries.keys.each do |entry|
JenkinsPipelineBuilder.registry.entries.each_key do |entry|
desc entry, "List all #{entry}"
define_method(entry) do
entries = JenkinsPipelineBuilder.registry.registry[:job][entry]
Expand Down
2 changes: 1 addition & 1 deletion lib/jenkins_pipeline_builder/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_settings_bag(item_bag, settings_bag = {})
bag = {}
return unless item.is_a?(Hash)

item.keys.each do |k|
item.each_key do |k|
val = item[k]
next unless val.is_a? String

Expand Down
4 changes: 2 additions & 2 deletions lib/jenkins_pipeline_builder/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Extension
parameters: []
}.freeze

EXT_METHODS.keys.each do |method_name|
EXT_METHODS.each_key do |method_name|
define_method method_name do |value = nil|
return instance_variable_get("@#{method_name}") if value.nil?

Expand Down Expand Up @@ -90,7 +90,7 @@ def check_parameters(value)

def errors
errors = {}
EXT_METHODS.keys.each do |name|
EXT_METHODS.each_key do |name|
errors[name] = 'Must be set' if send(name).nil?
end
errors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ParametersHelper < ExtensionHelper
# rubocop:disable CyclomaticComplexity
# rubocop:disable Metrics/CyclomaticComplexity
def param_type(param)
case param[:type]
when 'string'
Expand All @@ -18,5 +18,5 @@ def param_type(param)
'hudson.model.StringParameterDefinition'
end
end
# rubocop:enable CyclomaticComplexity
# rubocop:enable Metrics/CyclomaticComplexity
end
2 changes: 0 additions & 2 deletions lib/jenkins_pipeline_builder/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def bootstrap(path, project_name = nil)
publish(project_name || job_collection.projects.first[:name])
end

# rubocop:disable Metrics/AbcSize
def pull_request(path, project_name, base_branch_only = false)
logger.info "Pull Request Generator Running from path #{path}"
load_job_collection path unless job_collection.loaded?
Expand All @@ -73,7 +72,6 @@ def pull_request(path, project_name, base_branch_only = false)
end
errors.empty?
end
# rubocop:enable Metrics/AbcSize

def file(path, project_name)
logger.info "Generating files from path #{path}"
Expand Down
6 changes: 3 additions & 3 deletions lib/jenkins_pipeline_builder/job_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def load_file(path, remote = false)
hash.each do |section|
load_section section, remote
end
rescue StandardError => err
raise CustomErrors::ParseError.new err.message, path
rescue StandardError => e
raise CustomErrors::ParseError.new e.message, path
end

def load_section(section, remote)
Expand Down Expand Up @@ -122,7 +122,7 @@ def load_extensions(path)

logger.info "Loading extensions from folder #{path}"
logger.info Dir.glob("#{path}/*.rb").inspect
Dir.glob("#{path}/**/*.rb").each do |file|
Dir.glob("#{path}/**/*.rb").sort.each do |file|
logger.info "Loaded #{file}"
require file
end
Expand Down
4 changes: 4 additions & 0 deletions lib/jenkins_pipeline_builder/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ class Utils
def self.symbolize_keys_deep!(to_symbolize)
return unless to_symbolize.is_a?(Hash)

# This lint is disabled here because each_key requires that you not add or remove keys
# during iteration, which apparently this block does...
# rubocop:disable Style/HashEachMethods
to_symbolize.keys.each do |k|
ks = k.respond_to?(:to_sym) ? k.to_sym : k
to_symbolize[ks] = to_symbolize.delete k # Preserve order even when k == ks
symbolize_keys_deep! to_symbolize[ks] if to_symbolize[ks].is_a? Hash
to_symbolize[ks].each { |item| symbolize_keys_deep!(item) } if to_symbolize[ks].is_a?(Array)
end
# rubocop:enable Style/HashEachMethods
end

def self.symbolize_with_empty_hash!(array_of_maybe_str)
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 = '1.9.0'.freeze
VERSION = '1.9.1'.freeze
end
10 changes: 5 additions & 5 deletions spec/lib/jenkins_pipeline_builder/extensions/builders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@

begin
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
rescue RuntimeError => boom
puts "Caught error #{boom}"
error = boom.to_s
rescue RuntimeError => e
puts "Caught error #{e}"
error = e.to_s
end
builder = @n_xml.root.children.first
expect(builder.name).to match 'hudson.plugins.groovy.SystemGroovy'
Expand Down Expand Up @@ -407,8 +407,8 @@
)
begin
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
rescue RuntimeError => err
puts 'Runtime Error: ' + err.to_s
rescue RuntimeError => e
puts 'Runtime Error: ' + e.to_s
end
builder = @n_xml.root.children.first
expect(builder.name).to match 'jenkins.plugins.nodejs.NodeJsCommandInterpreter'
Expand Down

0 comments on commit dc7162c

Please sign in to comment.