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 +4 -4
- data/.gitignore +0 -1
- data/leeroy_jenkins.gemspec +22 -21
- data/lib/leeroy_jenkins/cli.rb +11 -3
- data/lib/leeroy_jenkins/job_finder.rb +12 -5
- data/lib/leeroy_jenkins/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4612f068204c29e5974fca44bc9caecb6748c7e9
|
4
|
+
data.tar.gz: a83a55f9e5611c7faedf56993f8c39c5118159eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3d432dd6f88cb2b13f19d74cb0749f9c5e6589b440d426c1a985632ab512e635e42f9ddf8e7e35aa1b04966d40c7774cb19cc32820859df58e25044ca79730e
|
7
|
+
data.tar.gz: c741588ce832eaf3faaa90db0c11293bb9bfb59e6597de287de584ec6e1f7e0dc73bb60786e786c155a8ec984ed739ac9d1d265384250886f3d54c450de14469
|
data/leeroy_jenkins.gemspec
CHANGED
@@ -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 =
|
7
|
+
spec.name = 'leeroy_jenkins'
|
8
8
|
spec.version = LeeroyJenkins::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Jeff Rabovsky']
|
10
|
+
spec.email = ['jeffr@jellyvision.com']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
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{^(
|
17
|
-
spec.bindir =
|
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 = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency
|
22
|
-
spec.add_dependency
|
23
|
-
spec.add_dependency
|
24
|
-
spec.add_dependency
|
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
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
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
|
data/lib/leeroy_jenkins/cli.rb
CHANGED
@@ -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
|
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],
|
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]
|
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 :
|
3
|
+
attr_reader :jenkins_client
|
4
4
|
|
5
|
-
def initialize(
|
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
|
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
|
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.
|
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:
|
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.
|
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
|