backup_jenkins 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -52,6 +52,7 @@ module BackupJenkins
52
52
  def copy_files
53
53
  create_dir_and_copy(plugin_files)
54
54
  create_dir_and_copy(user_content_files)
55
+ create_dir_and_copy(user_files)
55
56
  create_dir_and_copy(jobs_files)
56
57
  end
57
58
 
@@ -85,8 +86,22 @@ module BackupJenkins
85
86
  Dir["#{config.jenkins.home}/userContent/*"]
86
87
  end
87
88
 
89
+ def user_files
90
+ find_files('users', 'config.xml')
91
+ end
92
+
88
93
  def jobs_files
89
- `find #{config.jenkins.home}/jobs -maxdepth 3 -name config.xml -or -name nextBuildNumber`.split(/\n/)
94
+ find_files('jobs', 'config.xml', 'nextBuildNumber')
95
+ end
96
+
97
+ def find_files(base, *names)
98
+ `#{find_file_command(base, names)}`.split(%r{#{$/}})
99
+ end
100
+
101
+ def find_file_command(base, names)
102
+ path = File.join(config.jenkins.home, base)
103
+ names_str = names * " -or -name "
104
+ "find #{path} -maxdepth 3 -name #{names_str}"
90
105
  end
91
106
 
92
107
  def create_tarball
@@ -1,3 +1,3 @@
1
1
  module BackupJenkins
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -57,6 +57,7 @@ describe BackupJenkins::Backup do
57
57
  before do
58
58
  subject.stub(:plugin_files).and_return("plugin_files")
59
59
  subject.stub(:user_content_files).and_return("user_content_files")
60
+ subject.stub(:user_files).and_return("user_files")
60
61
  subject.stub(:jobs_files).and_return("jobs_files")
61
62
 
62
63
  subject.stub(:create_dir_and_copy)
@@ -66,6 +67,7 @@ describe BackupJenkins::Backup do
66
67
 
67
68
  it { subject.should_receive(:create_dir_and_copy).with("plugin_files") }
68
69
  it { subject.should_receive(:create_dir_and_copy).with("user_content_files") }
70
+ it { subject.should_receive(:create_dir_and_copy).with("user_files") }
69
71
  it { subject.should_receive(:create_dir_and_copy).with("jobs_files") }
70
72
  end
71
73
 
@@ -291,4 +293,16 @@ describe BackupJenkins::Backup do
291
293
  subject.send(:user_content_files).should == %w(my_file)
292
294
  end
293
295
  end
296
+
297
+ describe "#user_files" do
298
+ before { config.stub_chain(:jenkins, :home).and_return("home") }
299
+
300
+ it "should return the config.xml and nextBuildNumber files in job directories" do
301
+ subject.should_receive(:`).
302
+ with("find home/users -maxdepth 3 -name config.xml").
303
+ and_return("file1\nfile2\nfile3")
304
+ subject.send(:user_files).should == %w(file1 file2 file3)
305
+ end
306
+ end
307
+
294
308
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup_jenkins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-12 00:00:00.000000000 Z
12
+ date: 2012-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
16
- requirement: &29093460 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *29093460
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: hashie
27
- requirement: &29093040 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *29093040
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rake
38
- requirement: &29092620 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *29092620
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  description: Simple Jenkins config and plugin backup to S3
48
63
  email:
49
64
  - jcmuller@gmail.com
@@ -96,14 +111,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
111
  version: '0'
97
112
  requirements: []
98
113
  rubyforge_project:
99
- rubygems_version: 1.8.15
114
+ rubygems_version: 1.8.24
100
115
  signing_key:
101
116
  specification_version: 3
102
117
  summary: This gem allows you to get a backup instance of jenkins up and running pretty
103
118
  quickly
104
119
  test_files:
105
- - spec/lib/backup_jenkins/formatter_spec.rb
120
+ - spec/lib/backup_jenkins/aws_spec.rb
106
121
  - spec/lib/backup_jenkins/backup_spec.rb
107
122
  - spec/lib/backup_jenkins/cli_spec.rb
108
123
  - spec/lib/backup_jenkins/config_spec.rb
109
- - spec/lib/backup_jenkins/aws_spec.rb
124
+ - spec/lib/backup_jenkins/formatter_spec.rb
125
+ has_rdoc: