jenkins_pipeline_builder 0.2.0 → 0.2.2

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: f6388662ca895ddc734a5aba148075f4d1ca06ec
4
- data.tar.gz: e22efe806c6c5558996cd4af38629ebba14fff8a
3
+ metadata.gz: c085dfdc7cec7f2d1df4f4d46ec4d2a53854b0d1
4
+ data.tar.gz: 11741c96a3ffb283b2c88e6d9e2f90452eac2964
5
5
  SHA512:
6
- metadata.gz: 79c70051777c8cb7fef36c5666d4b7cc30d1bd8ca76a740dc46face5dcb844c34684f19d7139436dc63ad5157114b96ca9ea07aaf4c27be23aaf584e48c9e92a
7
- data.tar.gz: bbea1cdcae6fe68886f7e78461476b90a269448af4ae2166d9fd9692797252a222eae3ac5824e02040df7a1f180cc21459c6317178824264168983bed1b8c855
6
+ metadata.gz: 964a0077ffefc1a869fb1b1ba1f153e244c5752317270521294e3e058e20fb19866021c191f3c3f737357ce5f104ba0ecaaaed2ea9051fc58e9909e78a147456
7
+ data.tar.gz: 42f1dd78be906eef930b94e63ede816ddae53b859334e2726ad88a5fc1182001e2c8e56a96d0ea10571a5c13f4d620477891c3c255708601bc1e89962e522d22
data/.ackrc ADDED
@@ -0,0 +1,4 @@
1
+ --ignore-dir=docs
2
+ --ignore-dir=doc
3
+ --ignore-dir=out
4
+ --ignore-dir=coverage
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .*.swp
2
+ out
3
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --tty --format documentation
data/README.md CHANGED
@@ -104,17 +104,28 @@ Here's a high level overview of what's available:
104
104
  room: room name here
105
105
  start-notify: true
106
106
  builders:
107
- - job_builder:
108
- child_jobs:
109
- - job-name-1
110
- - job-name-2
111
- mark_phase: SUCCESSFUL
107
+ - multi_job:
108
+ phases:
109
+ "Phase One":
110
+ jobs:
111
+ - name: first
112
+ exposed_scm: true
113
+ current_params: true
114
+ config:
115
+ predefined_build_parameters:
116
+ - "PARENT_WORKSPACE=${WORKSPACE}"
117
+ - name: second
118
+ continue_condition: COMPLETED
119
+ "Phase Two":
120
+ jobs:
121
+ - name: third
112
122
  - inject_vars_file: build_job_info
113
123
  - shell_command: |
114
124
  echo 'Doing some work'
115
125
  run command1
116
126
  - maven3:
117
127
  goals: -B clean
128
+ rootPom: path_to_pom
118
129
  mavenName: maven-name # Optional
119
130
  wrappers:
120
131
  - timestamp: true
data/Rakefile CHANGED
@@ -66,3 +66,5 @@ namespace :doc do
66
66
  `dot jenkins_api_client.dot -Tpng -o jenkins_api_client_class_diagram.png`
67
67
  end
68
68
  end
69
+
70
+ task default: :unit_tests
@@ -22,28 +22,31 @@
22
22
 
23
23
  module JenkinsPipelineBuilder
24
24
  class Builders
25
- def self.build_multijob_builder(params, xml)
26
- xml.send('com.tikal.jenkins.plugins.multijob.MultiJobBuilder') {
27
- xml.phaseName 'Child Jobs'
28
- xml.phaseJobs {
29
- proc = lambda do |xml, name|
30
- xml.send('com.tikal.jenkins.plugins.multijob.PhaseJobsConfig') {
31
- xml.jobName name
32
- xml.currParams false
33
- xml.exposedSCM false
34
- xml.configs {
35
- xml.send('hudson.plugins.parameterizedtrigger.PredefinedBuildParameters') {
36
- xml.properties 'PARENT_WORKSPACE=${WORKSPACE}'
37
- }
25
+ def self.build_multijob(params, xml)
26
+ params[:phases].each do |name, content|
27
+ xml.send('com.tikal.jenkins.plugins.multijob.MultiJobBuilder') {
28
+ xml.phaseName name
29
+ xml.phaseJobs {
30
+ content[:jobs].each do |job|
31
+ xml.send('com.tikal.jenkins.plugins.multijob.PhaseJobsConfig') {
32
+ xml.jobName job[:name]
33
+ xml.currParams job[:current_params] || false
34
+ xml.exposedSCM job[:exposed_scm] || false
35
+ if job[:config]
36
+ xml.configs {
37
+ if job[:config].has_key? :predefined_build_parameters
38
+ xml.send('hudson.plugins.parameterizedtrigger.PredefinedBuildParameters') {
39
+ xml.properties job[:config][:predefined_build_parameters].join ' '
40
+ }
41
+ end
42
+ }
43
+ end
38
44
  }
39
- }
40
- end
41
- params[:child_jobs].each do |name|
42
- proc.call xml, name
43
- end
45
+ end
46
+ }
47
+ xml.continuationCondition content[:continue_condition] || 'SUCCESSFUL'
44
48
  }
45
- xml.continuationCondition params[:mark_phase]
46
- }
49
+ end
47
50
  end
48
51
 
49
52
  def self.build_maven3(params, xml)
@@ -78,4 +78,4 @@ module JenkinsPipelineBuilder
78
78
  return item
79
79
  end
80
80
  end
81
- end
81
+ end
@@ -38,6 +38,7 @@ module JenkinsPipelineBuilder
38
38
  def initialize(args, client)
39
39
  @client = client
40
40
  @logger = @client.logger
41
+ #@logger.level = (@debug) ? Logger::DEBUG : Logger::INFO;
41
42
  @job_templates = {}
42
43
  @job_collection = {}
43
44
 
@@ -49,7 +50,7 @@ module JenkinsPipelineBuilder
49
50
  parameters: JobBuilder.method(:build_parameters),
50
51
  builders: {
51
52
  registry: {
52
- job_builder: Builders.method(:build_multijob_builder),
53
+ multi_job: Builders.method(:build_multijob),
53
54
  inject_vars_file: Builders.method(:build_environment_vars_injector),
54
55
  shell_command: Builders.method(:build_shell_command),
55
56
  maven3: Builders.method(:build_maven3)
@@ -95,7 +96,14 @@ module JenkinsPipelineBuilder
95
96
  end
96
97
 
97
98
  attr_accessor :client
98
- attr_accessor :debug
99
+ #attr_accessor :debug
100
+ def debug=(value)
101
+ @debug = value
102
+ @logger.level = (value) ? Logger::DEBUG : Logger::INFO;
103
+ end
104
+ def debug
105
+ @debug
106
+ end
99
107
  # TODO: WTF?
100
108
  attr_accessor :no_files
101
109
  attr_accessor :job_collection
@@ -109,6 +117,7 @@ module JenkinsPipelineBuilder
109
117
  end
110
118
 
111
119
  def load_collection_from_path(path, recursively = false)
120
+ path = File.expand_path(path, relative_to=Dir.getwd)
112
121
  if File.directory?(path)
113
122
  @logger.info "Generating from folder #{path}"
114
123
  Dir[File.join(path, '/*.yaml'), File.join(path, '/*.yml')].each do |file|
@@ -183,6 +192,7 @@ module JenkinsPipelineBuilder
183
192
  job = get_item(name)
184
193
  raise "Failed to locate job by name '#{name}'" if job.nil?
185
194
  job_value = job[:value]
195
+ @logger.debug "Compiling job #{name}"
186
196
  compiled_job = Compiler.compile(job_value, settings)
187
197
  return compiled_job
188
198
  end
@@ -21,5 +21,5 @@
21
21
  #
22
22
 
23
23
  module JenkinsPipelineBuilder
24
- VERSION = "0.2.0"
24
+ VERSION = "0.2.2"
25
25
  end
@@ -23,16 +23,16 @@ describe JenkinsPipelineBuilder::View do
23
23
  def create_and_validate(params)
24
24
  name = params[:name]
25
25
  @valid_post_responses.should include(
26
- @generator.view.create(params).to_i
27
- )
26
+ @generator.view.create(params).to_i
27
+ )
28
28
  @generator.view.list_children(params[:parent_view], name).include?(name).should be_true
29
29
  end
30
30
 
31
31
  def destroy_and_validate(params)
32
32
  name = params[:name]
33
33
  @valid_post_responses.should include(
34
- @generator.view.delete(name, params[:parent_view]).to_i
35
- )
34
+ @generator.view.delete(name, params[:parent_view]).to_i
35
+ )
36
36
  @generator.view.list_children(params[:parent_view], name).include?(name).should be_false
37
37
  end
38
38
 
@@ -43,7 +43,7 @@ describe JenkinsPipelineBuilder::View do
43
43
 
44
44
  it 'accepts the name of the view and creates the view' do
45
45
  params = {
46
- :name => 'test_list_view'
46
+ :name => 'test_list_view'
47
47
  }
48
48
 
49
49
  test_and_validate(params)
@@ -51,15 +51,15 @@ describe JenkinsPipelineBuilder::View do
51
51
 
52
52
  it 'creates a Nested view with a child' do
53
53
  params_parent = {
54
- name: 'My Test Parent View',
55
- type: 'nestedView'
54
+ name: 'My Test Parent View',
55
+ type: 'nestedView'
56
56
  }
57
57
 
58
58
  create_and_validate(params_parent)
59
59
 
60
60
  params_child = {
61
- name: 'Test List View',
62
- parent_view: params_parent[:name]
61
+ name: 'Test List View',
62
+ parent_view: params_parent[:name]
63
63
  }
64
64
 
65
65
  test_and_validate(params_child)
@@ -69,20 +69,20 @@ describe JenkinsPipelineBuilder::View do
69
69
 
70
70
  it 'creates a categorized view with columns' do
71
71
  params = {
72
- name: 'test_category_view',
73
- type: 'categorizedView',
74
- description: 'Blah blah',
75
- regex: 'Job-.*',
76
- groupingRules: [{
77
- groupRegex: 'Step-1.*',
78
- namingRule: '1. Commit'
79
- },{
80
- groupRegex: 'Step-2.*',
81
- namingRule: '2. Acceptance'
82
- },{
83
- groupRegex: 'Step-3.*',
84
- namingRule: '3. Release'
85
- }]
72
+ name: 'test_category_view',
73
+ type: 'categorizedView',
74
+ description: 'Blah blah',
75
+ regex: 'Job-.*',
76
+ groupingRules: [{
77
+ groupRegex: 'Step-1.*',
78
+ namingRule: '1. Commit'
79
+ },{
80
+ groupRegex: 'Step-2.*',
81
+ namingRule: '2. Acceptance'
82
+ },{
83
+ groupRegex: 'Step-3.*',
84
+ namingRule: '3. Release'
85
+ }]
86
86
  }
87
87
 
88
88
  test_and_validate(params)
@@ -90,4 +90,4 @@ describe JenkinsPipelineBuilder::View do
90
90
  end
91
91
  end
92
92
  end
93
- end
93
+ end
@@ -16,4 +16,4 @@ describe 'Compiler' do
16
16
 
17
17
  result.should == hash
18
18
  end
19
- end
19
+ end
@@ -68,18 +68,34 @@
68
68
  <concurrentBuild>false</concurrentBuild>
69
69
  <builders>
70
70
  <com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
71
- <phaseName>Child Jobs</phaseName>
71
+ <phaseName>Phase One</phaseName>
72
72
  <phaseJobs>
73
73
  <com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
74
- <jobName>Child-Job</jobName>
75
- <currParams>false</currParams>
76
- <exposedSCM>false</exposedSCM>
74
+ <jobName>first</jobName>
75
+ <currParams>true</currParams>
76
+ <exposedSCM>true</exposedSCM>
77
77
  <configs>
78
78
  <hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
79
79
  <properties>PARENT_WORKSPACE=${WORKSPACE}</properties>
80
80
  </hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
81
81
  </configs>
82
82
  </com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
83
+ <com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
84
+ <jobName>second</jobName>
85
+ <currParams>false</currParams>
86
+ <exposedSCM>false</exposedSCM>
87
+ </com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
88
+ </phaseJobs>
89
+ <continuationCondition>COMPLETED</continuationCondition>
90
+ </com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
91
+ <com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
92
+ <phaseName>Phase Two</phaseName>
93
+ <phaseJobs>
94
+ <com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
95
+ <jobName>third</jobName>
96
+ <currParams>false</currParams>
97
+ <exposedSCM>false</exposedSCM>
98
+ </com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
83
99
  </phaseJobs>
84
100
  <continuationCondition>SUCCESSFUL</continuationCondition>
85
101
  </com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
@@ -19,10 +19,21 @@
19
19
  - git_push: true
20
20
  - scm_polling: "H/5 * * * *"
21
21
  builders:
22
- - job_builder:
23
- child_jobs:
24
- - Child-Job
25
- mark_phase: SUCCESSFUL
22
+ - multi_job:
23
+ phases:
24
+ "Phase One":
25
+ jobs:
26
+ - name: first
27
+ exposed_scm: true
28
+ current_params: true
29
+ config:
30
+ predefined_build_parameters:
31
+ - "PARENT_WORKSPACE=${WORKSPACE}"
32
+ - name: second
33
+ continue_condition: COMPLETED
34
+ "Phase Two":
35
+ jobs:
36
+ - name: third
26
37
  - inject_vars_file: build_job_info
27
38
  publishers:
28
39
  - downstream:
@@ -1,5 +1,4 @@
1
- require File.expand_path('../spec_helper', __FILE__)
2
- require 'equivalent-xml'
1
+ require 'unit_tests/spec_helper'
3
2
 
4
3
  describe 'Test YAML jobs conversion to XML' do
5
4
  context 'Loading YAML files' do
@@ -64,4 +63,4 @@ describe 'Test YAML jobs conversion to XML' do
64
63
  end
65
64
  end
66
65
  end
67
- end
66
+ end
@@ -22,6 +22,8 @@ end
22
22
  SimpleCov.start 'spec' #if ENV["COVERAGE"]
23
23
 
24
24
  require File.expand_path('../../../lib/jenkins_pipeline_builder', __FILE__)
25
+ require 'rspec/matchers'
26
+ require 'equivalent-xml'
25
27
 
26
28
  RSpec.configure do |config|
27
29
  config.before(:each) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jenkins_pipeline_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Moochnick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-16 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -258,6 +258,9 @@ executables:
258
258
  extensions: []
259
259
  extra_rdoc_files: []
260
260
  files:
261
+ - .ackrc
262
+ - .gitignore
263
+ - .rspec
261
264
  - .ruby-gemset
262
265
  - .ruby-version
263
266
  - Gemfile