jenkins_pipeline_builder 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +28 -43
  4. data/{spec/unit_tests/spec_helper.rb → .simplecov} +2 -15
  5. data/README.md +66 -11
  6. data/Rakefile +1 -25
  7. data/bin/generate +0 -1
  8. data/jenkins_pipeline_builder.gemspec +6 -6
  9. data/lib/jenkins_pipeline_builder.rb +14 -8
  10. data/lib/jenkins_pipeline_builder/builders.rb +207 -155
  11. data/lib/jenkins_pipeline_builder/cli/base.rb +1 -1
  12. data/lib/jenkins_pipeline_builder/cli/describe.rb +12 -8
  13. data/lib/jenkins_pipeline_builder/cli/list.rb +7 -7
  14. data/lib/jenkins_pipeline_builder/compiler.rb +62 -49
  15. data/lib/jenkins_pipeline_builder/extensions.rb +108 -0
  16. data/lib/jenkins_pipeline_builder/generator.rb +209 -160
  17. data/lib/jenkins_pipeline_builder/job_builder.rb +174 -105
  18. data/lib/jenkins_pipeline_builder/module_registry.rb +43 -59
  19. data/lib/jenkins_pipeline_builder/publishers.rb +166 -93
  20. data/lib/jenkins_pipeline_builder/pull_request.rb +7 -7
  21. data/lib/jenkins_pipeline_builder/triggers.rb +63 -40
  22. data/lib/jenkins_pipeline_builder/utils.rb +10 -10
  23. data/lib/jenkins_pipeline_builder/version.rb +1 -1
  24. data/lib/jenkins_pipeline_builder/view.rb +94 -123
  25. data/lib/jenkins_pipeline_builder/wrappers.rb +163 -96
  26. data/spec/lib/jenkins_pipeline_builder/compiler_spec.rb +31 -0
  27. data/spec/lib/jenkins_pipeline_builder/extensions_spec.rb +145 -0
  28. data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-10-SampleJob.yaml +2 -0
  29. data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-40-PullRequestGenerator.yaml +12 -0
  30. data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/project.yaml +12 -0
  31. data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/SamplePipeline-10-Commit.yaml +3 -0
  32. data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/SamplePipeline-20-Acceptance.yaml +3 -0
  33. data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/SamplePipeline-30-Release.yaml +3 -0
  34. data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/project.yaml +12 -0
  35. data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/view.yaml +5 -0
  36. data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/template_pipeline/jobs.tar.gz +0 -0
  37. data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/template_pipeline/project.yaml +15 -0
  38. data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/test_job.xml +48 -0
  39. data/spec/lib/jenkins_pipeline_builder/fixtures/view_test/duplicate_view.yaml +4 -0
  40. data/spec/lib/jenkins_pipeline_builder/fixtures/view_test/parent_view.yaml +9 -0
  41. data/spec/lib/jenkins_pipeline_builder/fixtures/view_test/regular_view.yaml +5 -0
  42. data/spec/lib/jenkins_pipeline_builder/generator_spec.rb +165 -0
  43. data/spec/lib/jenkins_pipeline_builder/module_registry_spec.rb +147 -0
  44. data/spec/lib/jenkins_pipeline_builder/pull_request_spec.rb +47 -0
  45. data/spec/lib/jenkins_pipeline_builder/spec_helper.rb +25 -0
  46. data/spec/lib/jenkins_pipeline_builder/utils_spec.rb +22 -0
  47. data/spec/lib/jenkins_pipeline_builder/view_spec.rb +54 -0
  48. metadata +54 -136
  49. data/lib/jenkins_pipeline_builder/extendable.rb +0 -42
  50. data/lib/jenkins_pipeline_builder/xml_helper.rb +0 -40
  51. data/spec/func_tests/spec_helper.rb +0 -18
  52. data/spec/func_tests/view_spec.rb +0 -90
  53. data/spec/unit_tests/compiler_spec.rb +0 -20
  54. data/spec/unit_tests/fixtures/files/Job-Build-Flow.xml +0 -57
  55. data/spec/unit_tests/fixtures/files/Job-Build-Flow.yaml +0 -22
  56. data/spec/unit_tests/fixtures/files/Job-Build-Maven.xml +0 -129
  57. data/spec/unit_tests/fixtures/files/Job-Build-Maven.yaml +0 -31
  58. data/spec/unit_tests/fixtures/files/Job-DSL.yaml +0 -14
  59. data/spec/unit_tests/fixtures/files/Job-DSL1.xml +0 -27
  60. data/spec/unit_tests/fixtures/files/Job-DSL2.xml +0 -25
  61. data/spec/unit_tests/fixtures/files/Job-Gem-Build.xml +0 -142
  62. data/spec/unit_tests/fixtures/files/Job-Gem-Build.yaml +0 -43
  63. data/spec/unit_tests/fixtures/files/Job-Generate-From-Template.xml +0 -32
  64. data/spec/unit_tests/fixtures/files/Job-Generate-From-Template.yaml +0 -8
  65. data/spec/unit_tests/fixtures/files/Job-Multi-Project.xml +0 -134
  66. data/spec/unit_tests/fixtures/files/Job-Multi-Project.yaml +0 -49
  67. data/spec/unit_tests/fixtures/files/archive_artifact.xml +0 -23
  68. data/spec/unit_tests/fixtures/files/archive_artifact.yaml +0 -5
  69. data/spec/unit_tests/fixtures/files/choice_parameter.xml +0 -39
  70. data/spec/unit_tests/fixtures/files/choice_parameter.yaml +0 -14
  71. data/spec/unit_tests/fixtures/files/concurrent_build.xml +0 -17
  72. data/spec/unit_tests/fixtures/files/concurrent_build.yaml +0 -4
  73. data/spec/unit_tests/fixtures/files/copy_artifact.xml +0 -30
  74. data/spec/unit_tests/fixtures/files/copy_artifact.yaml +0 -14
  75. data/spec/unit_tests/fixtures/files/discard_old.xml +0 -17
  76. data/spec/unit_tests/fixtures/files/discard_old.yaml +0 -8
  77. data/spec/unit_tests/fixtures/files/downstream.xml +0 -36
  78. data/spec/unit_tests/fixtures/files/downstream.yaml +0 -13
  79. data/spec/unit_tests/fixtures/files/downstream_blocking.xml +0 -19
  80. data/spec/unit_tests/fixtures/files/downstream_blocking.yaml +0 -15
  81. data/spec/unit_tests/fixtures/files/git_include_exclude.xml +0 -53
  82. data/spec/unit_tests/fixtures/files/git_include_exclude.yaml +0 -8
  83. data/spec/unit_tests/fixtures/files/groovy_postbuild.xml +0 -29
  84. data/spec/unit_tests/fixtures/files/groovy_postbuild.yaml +0 -9
  85. data/spec/unit_tests/fixtures/files/periodic_build.xml +0 -21
  86. data/spec/unit_tests/fixtures/files/periodic_build.yaml +0 -5
  87. data/spec/unit_tests/fixtures/files/post_build_script.xml +0 -28
  88. data/spec/unit_tests/fixtures/files/post_build_script.yaml +0 -11
  89. data/spec/unit_tests/fixtures/files/prepare_environment.xml +0 -17
  90. data/spec/unit_tests/fixtures/files/prepare_environment.yaml +0 -7
  91. data/spec/unit_tests/fixtures/files/project.yaml +0 -15
  92. data/spec/unit_tests/fixtures/files/properties_file.xml +0 -27
  93. data/spec/unit_tests/fixtures/files/properties_file.yaml +0 -8
  94. data/spec/unit_tests/fixtures/files/remote_job.xml +0 -18
  95. data/spec/unit_tests/fixtures/files/remote_job.yaml +0 -19
  96. data/spec/unit_tests/fixtures/files/rvm05.xml +0 -26
  97. data/spec/unit_tests/fixtures/files/rvm05.yaml +0 -5
  98. data/spec/unit_tests/fixtures/files/specific_priority.xml +0 -22
  99. data/spec/unit_tests/fixtures/files/specific_priority.yaml +0 -6
  100. data/spec/unit_tests/fixtures/files/throttle.xml +0 -17
  101. data/spec/unit_tests/fixtures/files/throttle.yaml +0 -8
  102. data/spec/unit_tests/fixtures/files/upstream.xml +0 -17
  103. data/spec/unit_tests/fixtures/files/upstream.yaml +0 -7
  104. data/spec/unit_tests/fixtures/pull_request/00.yaml +0 -14
  105. data/spec/unit_tests/fixtures/pull_request/10.yaml +0 -7
  106. data/spec/unit_tests/fixtures/pull_request/11.yaml +0 -4
  107. data/spec/unit_tests/fixtures/pull_request/project.yaml +0 -11
  108. data/spec/unit_tests/fixtures/templates/external_job.yaml +0 -4
  109. data/spec/unit_tests/fixtures/templates/project_with_jobs.yaml +0 -25
  110. data/spec/unit_tests/generator_spec.rb +0 -94
  111. data/spec/unit_tests/module_registry_spec.rb +0 -16
  112. data/spec/unit_tests/resolve_dependencies_spec.rb +0 -266
@@ -26,22 +26,22 @@ module JenkinsPipelineBuilder
26
26
  attr_reader :create
27
27
  attr_reader :jobs
28
28
 
29
- def initialize(project, job_collection, generator_job)
29
+ def initialize(project, jobs, pull_job)
30
30
  @purge = []
31
31
  @create = []
32
32
  @jobs = {}
33
33
 
34
- pull_requests = check_for_pull generator_job[:value]
34
+ pull_requests = check_for_pull pull_job
35
35
  purge_old(pull_requests, project)
36
36
  pull_requests.each do |number|
37
37
  # Manipulate the YAML
38
- req = JenkinsPipelineBuilder::PullRequest.new(project, number, job_collection, generator_job)
38
+ req = JenkinsPipelineBuilder::PullRequest.new(project, number, jobs, pull_job)
39
39
  @jobs.merge! req.jobs
40
- project_t = req.project
40
+ project_new = req.project
41
41
 
42
42
  # Overwrite the jobs from the generator to the project
43
- project_t[:value][:jobs] = generator_job[:value][:jobs]
44
- @create << project_t
43
+ project_new[:value][:jobs] = req.jobs.keys
44
+ @create << project_new
45
45
  end
46
46
  end
47
47
 
@@ -127,7 +127,7 @@ module JenkinsPipelineBuilder
127
127
  name = job[:name]
128
128
  changes = nil
129
129
  # Search the generator for changes
130
- @generator[:value][:jobs].each do |gen|
130
+ @generator[:jobs].each do |gen|
131
131
  changes = gen[name.to_sym] if gen.is_a?(Hash) && gen.keys[0] == name.to_sym
132
132
  end
133
133
  # Apply changes
@@ -18,53 +18,76 @@
18
18
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
19
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
20
  # THE SOFTWARE.
21
- #
22
21
 
23
- module JenkinsPipelineBuilder
24
- class Triggers < Extendable
25
- register :git_push do |_, xml|
26
- xml.send('com.cloudbees.jenkins.GitHubPushTrigger') do
27
- xml.spec
28
- end
22
+ trigger do
23
+ name :git_push
24
+ plugin_id 123
25
+ min_version 0
26
+ announced false
27
+
28
+ xml do |_|
29
+ send('com.cloudbees.jenkins.GitHubPushTrigger') do
30
+ spec
29
31
  end
32
+ end
33
+ end
30
34
 
31
- register :scm_polling do |scm_polling, xml|
32
- xml.send('hudson.triggers.SCMTrigger') do
33
- xml.spec scm_polling
34
- xml.ignorePostCommitHooks false
35
- end
35
+ trigger do
36
+ name :scm_polling
37
+ plugin_id 123
38
+ min_version 0
39
+ announced false
40
+
41
+ xml do |scm_polling|
42
+ send('hudson.triggers.SCMTrigger') do
43
+ spec scm_polling
44
+ ignorePostCommitHooks false
36
45
  end
46
+ end
47
+ end
37
48
 
38
- register :periodic_build do |periodic_build, xml|
39
- xml.send('hudson.triggers.TimerTrigger') do
40
- xml.spec periodic_build
41
- end
49
+ trigger do
50
+ name :periodic_build
51
+ plugin_id 123
52
+ min_version 0
53
+ announced false
54
+
55
+ xml do |periodic_build|
56
+ send('hudson.triggers.TimerTrigger') do
57
+ spec periodic_build
42
58
  end
59
+ end
60
+ end
43
61
 
44
- register :upstream do |params, xml|
45
- case params[:status]
46
- when 'unstable'
47
- name = 'UNSTABLE'
48
- ordinal = '1'
49
- color = 'yellow'
50
- when 'failed'
51
- name = 'FAILURE'
52
- ordinal = '2'
53
- color = 'RED'
54
- else
55
- name = 'SUCCESS'
56
- ordinal = '0'
57
- color = 'BLUE'
58
- end
59
- xml.send('jenkins.triggers.ReverseBuildTrigger') do
60
- xml.spec
61
- xml.upstreamProjects params[:projects]
62
- xml.send('threshold') do
63
- xml.name name
64
- xml.ordinal ordinal
65
- xml.color color
66
- xml.completeBuild true
67
- end
62
+ trigger do
63
+ name :upstream
64
+ plugin_id 123
65
+ min_version 0
66
+ announced false
67
+
68
+ xml do |params|
69
+ case params[:status]
70
+ when 'unstable'
71
+ name = 'UNSTABLE'
72
+ ordinal = '1'
73
+ color = 'yellow'
74
+ when 'failed'
75
+ name = 'FAILURE'
76
+ ordinal = '2'
77
+ color = 'RED'
78
+ else
79
+ name = 'SUCCESS'
80
+ ordinal = '0'
81
+ color = 'BLUE'
82
+ end
83
+ send('jenkins.triggers.ReverseBuildTrigger') do
84
+ spec
85
+ upstreamProjects params[:projects]
86
+ send('threshold') do
87
+ name name
88
+ ordinal ordinal
89
+ color color
90
+ completeBuild true
68
91
  end
69
92
  end
70
93
  end
@@ -20,27 +20,27 @@
20
20
  # THE SOFTWARE.
21
21
  #
22
22
 
23
- module JenkinsPipelineBuilder
24
- class ::Hash
25
- def deep_merge(second)
26
- merger = proc { |_key, v1, v2| v1.is_a?(Hash) && v2.is_a?(Hash) ? v1.merge(v2, &merger) : v2 }
27
- merge(second, &merger)
28
- end
23
+ class Hash
24
+ def deep_merge(second)
25
+ merger = proc { |_key, v1, v2| v1.is_a?(Hash) && v2.is_a?(Hash) ? v1.merge(v2, &merger) : v2 }
26
+ merge(second, &merger)
29
27
  end
28
+ end
30
29
 
30
+ module JenkinsPipelineBuilder
31
31
  class Utils
32
32
  # Code was duplicated from jeknins_api_client
33
33
  def self.symbolize_keys_deep!(h)
34
- return unless h.kind_of?(Hash)
34
+ return unless h.is_a?(Hash)
35
35
  h.keys.each do |k|
36
36
  ks = k.respond_to?(:to_sym) ? k.to_sym : k
37
37
  h[ks] = h.delete k # Preserve order even when k == ks
38
- symbolize_keys_deep! h[ks] if h[ks].kind_of? Hash
38
+ symbolize_keys_deep! h[ks] if h[ks].is_a? Hash
39
39
  h[ks].each { |item| symbolize_keys_deep!(item) } if h[ks].is_a?(Array)
40
40
  end
41
41
  end
42
- def self.hash_merge!(old, new)
43
- old.merge!(new) do |_key, old, new|
42
+ def self.hash_merge!(old_hash, new_hash)
43
+ old_hash.merge!(new_hash) do |_key, old, new|
44
44
  if old.is_a?(Hash) && new.is_a?(Hash)
45
45
  hash_merge!(old, new)
46
46
  else
@@ -21,5 +21,5 @@
21
21
  #
22
22
 
23
23
  module JenkinsPipelineBuilder
24
- VERSION = '0.5.2'
24
+ VERSION = '0.6.0'
25
25
  end
@@ -43,6 +43,78 @@ module JenkinsPipelineBuilder
43
43
  end
44
44
  end
45
45
 
46
+ # Creates a listview by accepting the given parameters hash
47
+ #
48
+ # @param [Hash] params options to create the new view
49
+ # @option params [String] :name Name of the view
50
+ # @option params [String] :type Description of the view
51
+ # @option params [String] :description Description of the view
52
+ # @option params [String] :status_filter Filter jobs based on the status.
53
+ # Valid options: all_selected_jobs, enabled_jobs_only,
54
+ # disabled_jobs_only. Default: all_selected_jobs
55
+ # @option params [Boolean] :filter_queue true or false
56
+ # @option params [Boolean] :filter_executors true or false
57
+ # @option params [String] :regex Regular expression to filter jobs that
58
+ # are to be added to the view
59
+ #
60
+ # @raise [ArgumentError] if the required parameter +:name+ is not
61
+ # specified
62
+ #
63
+ def create(params)
64
+ # Name is a required parameter. Raise an error if not specified
65
+ fail ArgumentError, 'Name is required for creating view' unless params.is_a?(Hash) && params[:name]
66
+ clean_up_views(params) unless @generator.debug
67
+ params[:type] ||= 'listview'
68
+ create_base_view(params[:name], params[:type], params[:parent_view])
69
+ @logger.debug "Creating a #{params[:type]} view with params: #{params.inspect}"
70
+
71
+ if @generator.debug
72
+ # pp post_params(params)
73
+ return
74
+ end
75
+
76
+ view_path = params[:parent_view].nil? ? '' : "/view/#{params[:parent_view]}"
77
+ view_path += "/view/#{params[:name]}/configSubmit"
78
+
79
+ @client.api_post_request(view_path, post_params(params))
80
+ end
81
+
82
+ private
83
+
84
+ def clean_up_views(params)
85
+ # If we have a parent view, we need to do some additional checks
86
+ if params[:parent_view]
87
+ create_base_view(params[:parent_view], 'nestedView') unless exists?(params[:parent_view])
88
+ delete(params[:name], params[:parent_view]) if exists?(params[:name], params[:parent_view])
89
+ else
90
+ delete(params[:name]) if exists?(params[:name])
91
+ end
92
+ end
93
+
94
+ def post_params(params)
95
+ statuses = { 'enabled_jobs_only' => '1', 'disabled_jobs_only' => '2' }
96
+
97
+ json = {
98
+ 'name' => params[:name],
99
+ 'description' => params[:description],
100
+ 'mode' => get_mode(params[:type]),
101
+ 'statusFilter' => '',
102
+ 'columns' => get_columns(params[:type])
103
+ }
104
+ json.merge!('groupingRules' => params[:groupingRules]) if params[:groupingRules]
105
+ payload = {
106
+ 'name' => params[:name],
107
+ 'mode' => get_mode(params[:type]),
108
+ 'description' => params[:description],
109
+ 'statusFilter' => statuses.fetch(params[:status_filter], ''),
110
+ 'json' => json.to_json
111
+ }
112
+ payload.merge!('filterQueue' => 'on') if params[:filter_queue]
113
+ payload.merge!('filterExecutors' => 'on') if params[:filter_executors]
114
+ payload.merge!('useincluderegex' => 'on', 'includeRegex' => params[:regex]) if params[:regex]
115
+ payload
116
+ end
117
+
46
118
  def get_mode(type)
47
119
  case type
48
120
  when 'listview'
@@ -81,7 +153,7 @@ module JenkinsPipelineBuilder
81
153
  }
82
154
 
83
155
  if @generator.debug
84
- pp initial_post_params
156
+ # pp initial_post_params
85
157
  return
86
158
  end
87
159
 
@@ -91,148 +163,47 @@ module JenkinsPipelineBuilder
91
163
  @client.api_post_request(view_path, initial_post_params)
92
164
  end
93
165
 
94
- # Creates a listview by accepting the given parameters hash
95
- #
96
- # @param [Hash] params options to create the new view
97
- # @option params [String] :name Name of the view
98
- # @option params [String] :type Description of the view
99
- # @option params [String] :description Description of the view
100
- # @option params [String] :status_filter Filter jobs based on the status.
101
- # Valid options: all_selected_jobs, enabled_jobs_only,
102
- # disabled_jobs_only. Default: all_selected_jobs
103
- # @option params [Boolean] :filter_queue true or false
104
- # @option params [Boolean] :filter_executors true or false
105
- # @option params [String] :regex Regular expression to filter jobs that
106
- # are to be added to the view
107
- #
108
- # @raise [ArgumentError] if the required parameter +:name+ is not
109
- # specified
110
- #
111
- def create(params)
112
- # Name is a required parameter. Raise an error if not specified
113
- fail ArgumentError, 'Name is required for creating view' unless params.is_a?(Hash) && params[:name]
114
- unless @generator.debug
115
- # If we have a parent view, we need to do some additional checks
116
- if params[:parent_view]
117
- # If there is no current parent view, create it
118
- unless @client.view.exists?(params[:parent_view])
119
- create_base_view(params[:parent_view], 'nestedView')
120
- end
121
- # If the view currently exists, delete it
122
- if exists?(params[:name], params[:parent_view])
123
- delete(params[:name], params[:parent_view])
124
- end
125
- else
126
- if @client.view.exists?(params[:name])
127
- @client.view.delete(params[:name])
128
- end
129
- end
166
+ def get_columns(type)
167
+ column_names = ['Status', 'Weather', 'Last Success', 'Last Failure', 'Last Duration', 'Build Button']
168
+ if type == 'categorizedView'
169
+ column_names << 'Categorized - Job'
170
+ else
171
+ column_names << 'Name'
130
172
  end
131
- params[:type] = 'listview' unless params[:type]
132
- create_base_view(params[:name], params[:type], params[:parent_view])
133
- @logger.debug "Creating a #{params[:type]} view with params: #{params.inspect}"
134
- status_filter = case params[:status_filter]
135
- when 'all_selected_jobs'
136
- ''
137
- when 'enabled_jobs_only'
138
- '1'
139
- when 'disabled_jobs_only'
140
- '2'
141
- else
142
- ''
143
- end
144
-
145
- json = {
146
- 'name' => params[:name],
147
- 'description' => params[:description],
148
- 'mode' => get_mode(params[:type]),
149
- 'statusFilter' => '',
150
- 'columns' => get_columns(params[:type])
151
- }
152
- json.merge!('groupingRules' => params[:groupingRules]) if params[:groupingRules]
153
- post_params = {
154
- 'name' => params[:name],
155
- 'mode' => get_mode(params[:type]),
156
- 'description' => params[:description],
157
- 'statusFilter' => status_filter,
158
- 'json' => json.to_json
159
- }
160
- post_params.merge!('filterQueue' => 'on') if params[:filter_queue]
161
- post_params.merge!('filterExecutors' => 'on') if params[:filter_executors]
162
- post_params.merge!('useincluderegex' => 'on',
163
- 'includeRegex' => params[:regex]) if params[:regex]
164
173
 
165
- if @generator.debug
166
- pp post_params
167
- return
174
+ result = []
175
+ column_names.each do |name|
176
+ result << columns_repository[name]
168
177
  end
169
-
170
- view_path = params[:parent_view].nil? ? '' : "/view/#{params[:parent_view]}"
171
- view_path += "/view/#{params[:name]}/configSubmit"
172
-
173
- @client.api_post_request(view_path, post_params)
178
+ result
174
179
  end
175
180
 
176
- def get_columns(type)
177
- columns_repository = {
178
- 'Status' =>
179
- {
180
- 'stapler-class' => 'hudson.views.StatusColumn',
181
- 'kind' => 'hudson.views.StatusColumn'
182
- },
183
- 'Weather' =>
184
- {
185
- 'stapler-class' => 'hudson.views.WeatherColumn',
186
- 'kind' => 'hudson.views.WeatherColumn'
187
- },
188
- 'Name' =>
189
- {
190
- 'stapler-class' => 'hudson.views.JobColumn',
191
- 'kind' => 'hudson.views.JobColumn'
192
- },
193
- 'Last Success' =>
194
- {
181
+ def columns_repository
182
+ {
183
+ 'Status' => { 'stapler-class' => 'hudson.views.StatusColumn', 'kind' => 'hudson.views.StatusColumn' },
184
+ 'Weather' => { 'stapler-class' => 'hudson.views.WeatherColumn', 'kind' => 'hudson.views.WeatherColumn' },
185
+ 'Name' => { 'stapler-class' => 'hudson.views.JobColumn', 'kind' => 'hudson.views.JobColumn' },
186
+ 'Last Success' => {
195
187
  'stapler-class' => 'hudson.views.LastSuccessColumn',
196
188
  'kind' => 'hudson.views.LastSuccessColumn'
197
189
  },
198
- 'Last Failure' =>
199
- {
190
+ 'Last Failure' => {
200
191
  'stapler-class' => 'hudson.views.LastFailureColumn',
201
192
  'kind' => 'hudson.views.LastFailureColumn'
202
193
  },
203
- 'Last Duration' =>
204
- {
194
+ 'Last Duration' => {
205
195
  'stapler-class' => 'hudson.views.LastDurationColumn',
206
196
  'kind' => 'hudson.views.LastDurationColumn'
207
197
  },
208
- 'Build Button' =>
209
- {
198
+ 'Build Button' => {
210
199
  'stapler-class' => 'hudson.views.BuildButtonColumn',
211
200
  'kind' => 'hudson.views.BuildButtonColumn'
212
201
  },
213
- 'Categorized - Job' =>
214
- {
202
+ 'Categorized - Job' => {
215
203
  'stapler-class' => 'org.jenkinsci.plugins.categorizedview.IndentedJobColumn',
216
204
  'kind' => 'org.jenkinsci.plugins.categorizedview.IndentedJobColumn'
217
205
  }
218
206
  }
219
-
220
- column_names = case type
221
- when 'categorizedView'
222
- ['Status', 'Weather', 'Categorized - Job', 'Last Success', 'Last Failure', 'Last Duration', 'Build Button']
223
- else
224
- ['Status', 'Weather', 'Name', 'Last Success', 'Last Failure', 'Last Duration', 'Build Button']
225
- end
226
-
227
- result = []
228
- column_names.each do |name|
229
- result << columns_repository[name]
230
- end
231
- result
232
- end
233
-
234
- def path_encode(path)
235
- URI.escape(path.encode(Encoding::UTF_8))
236
207
  end
237
208
 
238
209
  # This method lists all views
@@ -274,7 +245,7 @@ module JenkinsPipelineBuilder
274
245
  if parent_view
275
246
  list_children(parent_view, view_name).include?(view_name)
276
247
  else
277
- list(view_name).include?(view_name)
248
+ @client.view.list(view_name).include?(view_name)
278
249
  end
279
250
  end
280
251
  end