jenkins_pipeline_builder 0.13.3 → 0.13.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDc1ZDNkY2I3M2NkYTk4OThlMTNlMjA0MDkwN2QwYmU0MzEyMzVjNg==
4
+ ZmI1MTFmZmVkYmNkODgyMGYzNmZjYjFhMmUxZmFlZjkwYzU1MGNkYQ==
5
5
  data.tar.gz: !binary |-
6
- ZmM5YTA3NWZkYzRmZWYwMDE1Y2I0ZThhNjM0ZDY4YTAxZmNiYTlkNw==
6
+ ODFhNzAzMjA0ODI5Mjg1MTI0YjMwZDgyMDk2YmM5MmJmYjlhOWYyOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTBkM2VhYTMzOTNjZTA2NWVkYjgzNjQ4MzE3N2Y4OGIyNjQ1YWZjNmZhMWEw
10
- NzA2YmE5OWJlNzUzNzg0OTYxYWJjOGM3ODE1NjczNzFkMzQwZjRhOTI0NTAx
11
- ODk2NGFkNTgzMjQ5N2VlYjljZWNmNmE2MWNlMmE3MTgyZTE2MDE=
9
+ YTE1NjRhYWUyZGRjMDBiNTE0NWFlY2U1NDI0Y2YwMjI5NTU3NDAwMTI5MDlj
10
+ M2Q1NWM4Njc0YzljNDUwNjgyODQ1ZGZhMjY4ZjcwNTQxOWFhZGQxM2EyZWEx
11
+ ZDFkMjk0NTkyZTlmY2FhMzU5Y2M0ODEwYzMyNjczMTMzOTA2Mjk=
12
12
  data.tar.gz: !binary |-
13
- Zjc4M2JlNTkyMDYwMmNkMzhkNmIzYTBkOTVjMmE3MGFiNzc2YmQwMDhhMmJk
14
- MTA2Yjc0MzFlMzU1ODczODlkNjgyMzE2NjE5OThhMjc2MDdkYjA3NTZmOTdm
15
- ZmNlMzhmY2U4NGEyZmQ4OTQ4NDkxMDdjNGUzMGNhOTAyODlhNTM=
13
+ NWI0YjJhMjU2ZjUzZWNhZDdjZTk5OTU3NjE2NmQxYmRmNTZjNjdhMzJjZDYy
14
+ NTZkMDc1YjRjNjhkMTNkNmQ3YjJkNjFkNGU4MDkxNjMxNTUwNGEwYzVlYmY4
15
+ NWEwNmEwMTZhNGExZjJjZWIxM2FhMDk3ZGU5MGYwYmI4OTUxYTc=
@@ -37,6 +37,7 @@ require 'jenkins_pipeline_builder/generator'
37
37
  module JenkinsPipelineBuilder
38
38
  class << self
39
39
  attr_reader :client, :credentials, :debug, :file_mode
40
+ attr_writer :logger
40
41
  def generator
41
42
  @_generator ||= Generator.new
42
43
  end
@@ -51,23 +52,22 @@ module JenkinsPipelineBuilder
51
52
 
52
53
  def debug!
53
54
  @debug = true
54
- @client.logger.level = Logger::DEBUG
55
+ logger.level = Logger::DEBUG
55
56
  end
56
57
 
57
58
  def no_debug!
58
59
  @debug = false
59
- @client.logger.level = Logger::INFO
60
+ logger.level = Logger::INFO
60
61
  end
61
62
 
62
63
  def credentials=(creds)
63
64
  @credentials = creds
64
65
  @client = JenkinsApi::Client.new(credentials)
65
- generator.logger = @client.logger
66
66
  @credentials
67
67
  end
68
68
 
69
69
  def logger
70
- client.logger
70
+ @logger ||= client ? client.logger : Logger.new(STDOUT)
71
71
  end
72
72
 
73
73
  def registry
@@ -24,7 +24,7 @@ require 'json'
24
24
 
25
25
  module JenkinsPipelineBuilder
26
26
  class Generator
27
- attr_accessor :no_files, :job_templates, :logger, :module_registry, :job_collection
27
+ attr_accessor :no_files, :job_templates, :module_registry, :job_collection
28
28
 
29
29
  def initialize
30
30
  @job_templates = {}
@@ -45,15 +45,20 @@ module JenkinsPipelineBuilder
45
45
  JenkinsPipelineBuilder::View.new(self)
46
46
  end
47
47
 
48
+ def projects(path)
49
+ load_job_collection path unless job_collection.loaded?
50
+ job_collection.projects.map { |p| p[:name] }
51
+ end
52
+
48
53
  def bootstrap(path, project_name = nil)
49
54
  logger.info "Bootstrapping pipeline from path #{path}"
50
- load_job_collection path
55
+ load_job_collection path unless job_collection.loaded?
51
56
  publish(project_name || job_collection.projects.first[:name])
52
57
  end
53
58
 
54
59
  def pull_request(path, project_name)
55
60
  logger.info "Pull Request Generator Running from path #{path}"
56
- load_job_collection path
61
+ load_job_collection path unless job_collection.loaded?
57
62
  defaults = job_collection.defaults[:value]
58
63
  pr_generator = PullRequestGenerator.new defaults
59
64
  pr_generator.delete_closed_prs
@@ -1,10 +1,13 @@
1
1
  module JenkinsPipelineBuilder
2
2
  class JobCollection
3
3
  attr_accessor :collection, :remote_dependencies
4
+ attr_reader :loaded
5
+ alias_method :loaded?, :loaded
4
6
 
5
7
  def initialize
6
8
  @collection = {}
7
9
  @remote_dependencies = RemoteDependencies.new self
10
+ @loaded = false
8
11
  end
9
12
 
10
13
  def clear_remote_dependencies
@@ -61,6 +64,7 @@ module JenkinsPipelineBuilder
61
64
  else
62
65
  load_file(path, remote)
63
66
  end
67
+ @loaded = true
64
68
  end
65
69
 
66
70
  private
@@ -21,5 +21,5 @@
21
21
  #
22
22
 
23
23
  module JenkinsPipelineBuilder
24
- VERSION = '0.13.3'
24
+ VERSION = '0.13.4'
25
25
  end
@@ -0,0 +1,3 @@
1
+ - job:
2
+ name: '{{name}}-10-Commit'
3
+ description: '{{description}}'
@@ -0,0 +1,3 @@
1
+ - job:
2
+ name: '{{name}}-20-Acceptance'
3
+ description: '{{description}}'
@@ -0,0 +1,3 @@
1
+ - job:
2
+ name: '{{name}}-30-Release'
3
+ description: '{{description}}'
@@ -0,0 +1,28 @@
1
+ - defaults:
2
+ name: global
3
+ description: 'Test pipeline for generator_spec.rb'
4
+
5
+ - project:
6
+ name: SamplePipeline1
7
+ jobs:
8
+ - '{{name}}-10-Commit'
9
+ - '{{name}}-20-Acceptance'
10
+ - '{{name}}-30-Release'
11
+ views:
12
+ - '{{name}} View'
13
+ - project:
14
+ name: SamplePipeline2
15
+ jobs:
16
+ - '{{name}}-10-Commit'
17
+ - '{{name}}-20-Acceptance'
18
+ - '{{name}}-30-Release'
19
+ views:
20
+ - '{{name}} View'
21
+ - project:
22
+ name: SamplePipeline3
23
+ jobs:
24
+ - '{{name}}-10-Commit'
25
+ - '{{name}}-20-Acceptance'
26
+ - '{{name}}-30-Release'
27
+ views:
28
+ - '{{name}} View'
@@ -0,0 +1,5 @@
1
+ - view:
2
+ name: '{{name}} View'
3
+ type: 'listview'
4
+ description: '{{description}}'
5
+ regex: '{{name}}.*'
@@ -231,6 +231,13 @@ describe JenkinsPipelineBuilder::Generator do
231
231
  end
232
232
  end
233
233
 
234
+ describe '#projects' do
235
+ it 'returns a list of projects' do
236
+ path = File.expand_path('../fixtures/generator_tests/multi_project', __FILE__)
237
+ expect(@generator.projects path).to eq %w(SamplePipeline1 SamplePipeline2 SamplePipeline3)
238
+ end
239
+ end
240
+
234
241
  describe '#file_mode' do
235
242
  before :each do
236
243
  allow(JenkinsPipelineBuilder.client).to receive(:plugin).and_return double(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jenkins_pipeline_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.3
4
+ version: 0.13.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Moochnick
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-20 00:00:00.000000000 Z
12
+ date: 2015-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -395,6 +395,11 @@ files:
395
395
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/local_override/remote_and_local/10.yaml
396
396
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/local_override/remote_and_local/jobs.tar.gz
397
397
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/local_override/remote_and_local/project.yaml
398
+ - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/multi_project/SamplePipeline-10-Commit.yaml
399
+ - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/multi_project/SamplePipeline-20-Acceptance.yaml
400
+ - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/multi_project/SamplePipeline-30-Release.yaml
401
+ - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/multi_project/project.yaml
402
+ - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/multi_project/view.yaml
398
403
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-10-SampleJob.yaml
399
404
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-40-PullRequestGenerator.yaml
400
405
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/project.yaml
@@ -472,6 +477,11 @@ test_files:
472
477
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/local_override/remote_and_local/10.yaml
473
478
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/local_override/remote_and_local/jobs.tar.gz
474
479
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/local_override/remote_and_local/project.yaml
480
+ - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/multi_project/SamplePipeline-10-Commit.yaml
481
+ - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/multi_project/SamplePipeline-20-Acceptance.yaml
482
+ - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/multi_project/SamplePipeline-30-Release.yaml
483
+ - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/multi_project/project.yaml
484
+ - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/multi_project/view.yaml
475
485
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-10-SampleJob.yaml
476
486
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-40-PullRequestGenerator.yaml
477
487
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/project.yaml