leeroy_jenkins 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2242b274021374071a8a875054dff73696fe88aa
4
- data.tar.gz: ca61985f4c7522b1b03bf650c7a23e88e3d43075
3
+ metadata.gz: 4612f068204c29e5974fca44bc9caecb6748c7e9
4
+ data.tar.gz: a83a55f9e5611c7faedf56993f8c39c5118159eb
5
5
  SHA512:
6
- metadata.gz: 5e5dd418be25d92ddc549d66ec85ca7d61c7c5636c1ddc4fcf8ef3cd81c00fbc3a2c1bb899b894fe478c9c1a4fd7ff6c424c13c48a8e41f00178070a13be0d49
7
- data.tar.gz: e827f028f685ad9962112183f3aa425e73b722a513eeb9dfb0ac234a9b81f6a0f19b3c3c0adfe3e2ca8dddb8f676e35c125f4949041339ef79f8697d8d7b2e35
6
+ metadata.gz: f3d432dd6f88cb2b13f19d74cb0749f9c5e6589b440d426c1a985632ab512e635e42f9ddf8e7e35aa1b04966d40c7774cb19cc32820859df58e25044ca79730e
7
+ data.tar.gz: c741588ce832eaf3faaa90db0c11293bb9bfb59e6597de287de584ec6e1f7e0dc73bb60786e786c155a8ec984ed739ac9d1d265384250886f3d54c450de14469
data/.gitignore CHANGED
@@ -7,5 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
-
11
10
  .vagrant
@@ -4,31 +4,32 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'leeroy_jenkins/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "leeroy_jenkins"
7
+ spec.name = 'leeroy_jenkins'
8
8
  spec.version = LeeroyJenkins::VERSION
9
- spec.authors = ["Jeff Rabovsky"]
10
- spec.email = ["jeffr@jellyvision.com"]
9
+ spec.authors = ['Jeff Rabovsky']
10
+ spec.email = ['jeffr@jellyvision.com']
11
11
 
12
- spec.summary = %q{A CLI tool for managing Jenkins job configurations}
13
- spec.homepage = "https://github.com/Jellyvision/leeroy_jenkins"
14
- spec.license = "MIT"
12
+ spec.summary = 'A CLI tool for managing Jenkins job configurations'
13
+ spec.homepage = 'https://github.com/Jellyvision/leeroy_jenkins'
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "exe"
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features)/}) }
17
+ spec.bindir = 'exe'
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency "jenkins_api_client", "~> 1.4"
22
- spec.add_dependency "thor", "~> 0.19.1"
23
- spec.add_dependency "nokogiri", "~> 1.6"
24
- spec.add_dependency "parallel", "~> 1.6"
21
+ spec.add_dependency 'jenkins_api_client', '~> 1.4'
22
+ spec.add_dependency 'thor', '~> 0.19.1'
23
+ spec.add_dependency 'nokogiri', '~> 1.6'
24
+ spec.add_dependency 'parallel', '~> 1.6'
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.10"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rspec", "~> 3.3"
29
- spec.add_development_dependency "aruba", "~> 0.9.0"
30
- spec.add_development_dependency "cucumber", "~> 2.1"
31
- spec.add_development_dependency "pry", "~> 0.10.1"
32
- spec.add_development_dependency "pry-doc", "~> 0.8.0"
33
- spec.add_development_dependency "pry-stack_explorer", "~> 0.4.9"
26
+ spec.add_development_dependency 'bundler', '~> 1.10'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.3'
29
+ spec.add_development_dependency 'aruba', '~> 0.9.0'
30
+ spec.add_development_dependency 'cucumber', '~> 2.1'
31
+ spec.add_development_dependency 'pry', '~> 0.10.1'
32
+ spec.add_development_dependency 'pry-doc', '~> 0.8.0'
33
+ spec.add_development_dependency 'pry-stack_explorer', '~> 0.4.9'
34
+ spec.add_development_dependency 'rubocop', '~> 0.37.2'
34
35
  end
@@ -13,6 +13,7 @@ module LeeroyJenkins
13
13
  option :xpath, required: false, type: :string, desc: 'XPath of node(s) to modify in the config.xml of the specified job(s)', default: '/'
14
14
  option :dry_run, type: :boolean, desc: 'Write XML to STDOUT instead of to Jenkins', default: true
15
15
  option :at_xpath, required: false, type: :string, desc: 'Replace, append to, or delete the XML node(s) specified by the given XPath', enum: ['replace', 'append', 'delete'], default: 'replace'
16
+ option :jobs, required: false, type: :string, desc: 'Path to a file containing a job name on each line'
16
17
  def update_config
17
18
  raw_xml_string = File.read options[:new_xml]
18
19
  if error = LeeroyJenkins.invalid_xml_document?(raw_xml_string)
@@ -20,9 +21,16 @@ module LeeroyJenkins
20
21
  exit 1
21
22
  end
22
23
 
23
- jenkins_client = build_jenkins_client options
24
+ jenkins_client = build_jenkins_client(options)
25
+
26
+ job_rows =
27
+ if options[:jobs]
28
+ File.read(options[:jobs]).split("\n")
29
+ else
30
+ nil
31
+ end
24
32
 
25
- job_names_to_update = JobFinder.new(options[:job_regex], jenkins_client).find_jobs
33
+ job_names_to_update = JobFinder.new(jenkins_client).find_jobs(options[:job_regex], job_rows)
26
34
  job_updater = JobUpdater.new job_names_to_update, raw_xml_string, jenkins_client, options[:xpath], options[:at_xpath], options[:threads]
27
35
  result = options[:dry_run] ? job_updater.dry_run : job_updater.update_jobs!
28
36
 
@@ -44,7 +52,7 @@ module LeeroyJenkins
44
52
  option :backup_dir, required: true, type: :string, desc: 'Path to the directory to save the config.xml file to, created if it does not exist'
45
53
  def backup
46
54
  jenkins_client = build_jenkins_client options
47
- job_names_to_backup = JobFinder.new(options[:job_regex], jenkins_client).find_jobs
55
+ job_names_to_backup = JobFinder.new(jenkins_client).find_jobs(options[:job_regex])
48
56
  JobBackupper.new(job_names_to_backup, jenkins_client, options[:backup_dir], options[:threads]).backup
49
57
  end
50
58
 
@@ -1,14 +1,21 @@
1
1
  module LeeroyJenkins
2
2
  class JobFinder
3
- attr_reader :regex, :jenkins_client
3
+ attr_reader :jenkins_client
4
4
 
5
- def initialize(regex, jenkins_client)
6
- @regex = regex
5
+ def initialize(jenkins_client)
7
6
  @jenkins_client = jenkins_client
8
7
  end
9
8
 
10
- def find_jobs
11
- jenkins_client.job.list regex
9
+ def find_jobs(regex, job_names = nil)
10
+ jobs_matching_regex = jenkins_client.job.list(regex)
11
+
12
+ if job_names
13
+ jobs_matching_regex.select do |job|
14
+ job_names.include? job
15
+ end
16
+ else
17
+ jobs_matching_regex
18
+ end
12
19
  end
13
20
  end
14
21
  end
@@ -1,3 +1,3 @@
1
1
  module LeeroyJenkins
2
- VERSION = "0.2.1"
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leeroy_jenkins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Rabovsky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-07 00:00:00.000000000 Z
11
+ date: 2016-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jenkins_api_client
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: 0.4.9
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 0.37.2
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 0.37.2
181
195
  description:
182
196
  email:
183
197
  - jeffr@jellyvision.com
@@ -225,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
239
  version: '0'
226
240
  requirements: []
227
241
  rubyforge_project:
228
- rubygems_version: 2.4.5.1
242
+ rubygems_version: 2.5.1
229
243
  signing_key:
230
244
  specification_version: 4
231
245
  summary: A CLI tool for managing Jenkins job configurations