jenkins_pipeline_builder 0.11.2 → 0.12.0

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
- MThjM2Q2MDE2YmY4OGZmNDc1ODdlYzM3NmViNGQ2NTQyMzcwMGMyYQ==
4
+ NTI4NWI4YWJjMDk4MzJiNzgzMTAwZWJhYzE0ZDJmYTQzYWFlZDEyYw==
5
5
  data.tar.gz: !binary |-
6
- ZjJlZjk0MWIwOGVkZWI1NWNlYzUwZjFkNGE0YThlYzhkYzBhNjc0Mw==
6
+ YmJiMGY3NzU0ODEwY2ZkMzUyZGZjOTQzZTlmZGRkMTRiMzVkMDIxMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjdhYzliMzJjZWFiMDkzYTFjNGJlMmU1OTA3NzViOGQ4OTdiOGE4N2Y5YWVj
10
- ZTZmYzBiODBjNGQzMzRkMTJhZWEwZGZmZTFlNjQ1ZjE5NjFkMDZiYjVhMmIz
11
- YzkyNzBlNmQ0YTY4NTQwMTdmNDA2N2FjYmU1YWI1YjViOGMwOGY=
9
+ MTVjYmM2M2E4MjZiM2RjNTQ3OTIyZTdlMTgxOTE3MGMzZGQyZmQ4M2VlNTgz
10
+ YTVmZmQxZGFjZjU0YmZjNDYxM2Q4MWI0ZTlmZmYxZGQ0YTBkOGVkMGEzYzMz
11
+ YTY4ZjM2OTVmMDI2NWNlMzc4ZTZiNTE0M2JhM2E4ZDY1MGFhYmI=
12
12
  data.tar.gz: !binary |-
13
- ODRmNDRiMTU0NzhlYzgzYzRlMDc1MDU4OGE5OWFhYTNmNDFiNzE5NjdhNGZj
14
- NDE1MTUzMjFmYmI5MWM4NjkyNTIxYTNhMzVjMmMyZDg0MzkxNDc3YmFkNmJi
15
- M2ZkMDAxM2Q5YmQ4NTQ2ZjIyZjA5Nzc3OGZmZjc1MTQ3OTFmZjM=
13
+ ZWM5MzhiOGU2MGY5NWMzZGU4NGVjYTc3NzdhYjlhNzEzZDNjN2Q2YTg3NTVk
14
+ YzYxYjgwZDJkMzY1YTgxODk0Y2M5ZmVhOGUyZWNmZGE4NzBiMmNlYmE3ZmFk
15
+ NDIyMzY0NDU1ZTJjNzRhYzVjMTEyMWU2Y2U3MzkxYzlhMjQ1Y2Y=
@@ -5,7 +5,7 @@ Metrics/AbcSize:
5
5
  Metrics/MethodLength:
6
6
  Max: 20
7
7
  Metrics/ClassLength:
8
- Max: 180
8
+ Max: 190
9
9
 
10
10
  #######
11
11
  # Finalized settings
@@ -27,6 +27,7 @@ require 'jenkins_api_client'
27
27
  require 'open-uri'
28
28
  require 'zlib'
29
29
  require 'archive/tar/minitar'
30
+ require 'resolv'
30
31
 
31
32
  module JenkinsPipelineBuilder
32
33
  module CLI
@@ -296,3 +296,59 @@ builder do
296
296
  end
297
297
  end
298
298
  end
299
+
300
+ builder do
301
+ name :checkmarx_scan
302
+ plugin_id 'checkmarx'
303
+ description 'Jenkins plugin for checkmarx security audit'
304
+ jenkins_name 'Trigger a checkmarx security audit of your build'
305
+ announced false
306
+ parameters [
307
+ :serverUrl,
308
+ :useOwnServerCredentials,
309
+ :username,
310
+ :password,
311
+ :incremental,
312
+ :isThisBuildIncremental,
313
+ :projectName,
314
+ :groupId,
315
+ :skipSCMTriggers,
316
+ :waitForResultsEnabled,
317
+ :vulnerabilityThresholdEnabled,
318
+ :highThreshold,
319
+ :mediumThreshold,
320
+ :lowThreshold,
321
+ :preset,
322
+ :presetSpecified,
323
+ :generatePdfReport,
324
+ :excludeFolders,
325
+ :fullScansScheduled,
326
+ :filterPattern
327
+ ]
328
+
329
+ xml do |params|
330
+ send('com.checkmarx.jenkins.CxScanBuilder', 'plugin' => 'checkmarx@7.1.8-24') do
331
+ useOwnServerCredentials params[:useOwnServerCredentials]
332
+ serverUrl params[:serverUrl]
333
+ useOwnServerCredentials params[:useOwnServerCredentials]
334
+ username params[:username]
335
+ password params[:password]
336
+ incremental params[:incremental]
337
+ isThisBuildIncremental params[:isThisBuildIncremental]
338
+ projectName params[:projectName]
339
+ groupId params[:groupId]
340
+ skipSCMTriggers params[:skipSCMTriggers]
341
+ waitForResultsEnabled params[:waitForResultsEnabled]
342
+ vulnerabilityThresholdEnabled params[:vulnerabilityThresholdEnabled]
343
+ highThreshold params[:highThreshold]
344
+ mediumThreshold params[:mediumThreshold]
345
+ lowThreshold params[:lowThreshold]
346
+ generatePdfReport params[:generatePdfReport]
347
+ excludeFolders params[:excludeFolders]
348
+ presetSpecified params[:presetSpecified]
349
+ preset params[:preset]
350
+ fullScansScheduled params[:fullScansScheduled]
351
+ filterPattern params[:filterPattern]
352
+ end
353
+ end
354
+ end
@@ -77,8 +77,7 @@ job_attribute do
77
77
  # XML preprocessing
78
78
  # TODO: Actually figure out how to merge using the builder DSL
79
79
  # This delete the things we are going to add later is pretty crappy
80
- # Alternately don't use/tweak the xml the api client generates
81
- # (which is where I assume this is coming from)
80
+ # Alternately don't use/tweak the xml the jenkins_api_client generates
82
81
  before do |params|
83
82
  xpath('//scm/localBranch').remove if params[:local_branch]
84
83
  xpath('//scm/recursiveSubmodules').remove if params[:recursive_update]
@@ -126,13 +125,20 @@ job_attribute do
126
125
  :refspec,
127
126
  :remote_name,
128
127
  :remote_url,
128
+ :skip_tag,
129
129
  :wipe_workspace
130
130
  ]
131
131
 
132
132
  before do |params|
133
133
  remote_url = xpath('//scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/url').first
134
134
  params[:remote_url] = remote_url.content if remote_url
135
+
136
+ # XML preprocessing
137
+ # TODO: Actually figure out how to merge using the builder DSL
138
+ # This delete the things we are going to add later is pretty crappy
139
+ # Alternately don't use/tweak the xml the jenkins_api_client generates
135
140
  xpath('//scm/userRemoteConfigs').remove
141
+ xpath('//scm/skipTag').remove if params[:skip_tag]
136
142
  end
137
143
 
138
144
  xml path: '//scm' do |params|
@@ -147,6 +153,7 @@ job_attribute do
147
153
  end
148
154
  doGenerateSubmoduleConfigurations false
149
155
  submoduleCfg
156
+ skipTag params[:skip_tag] if params[:skip_tag]
150
157
  extensions do
151
158
  if params[:changelog_to_branch]
152
159
  opts = params[:changelog_to_branch]
@@ -305,7 +305,7 @@ publisher do
305
305
 
306
306
  xml do |params|
307
307
  send('hudson.plugins.sonar.SonarPublisher') do
308
- jdk '(Inherit From Job)'
308
+ jdk params[:jdk] || '(Inherit From Job)'
309
309
  branch params[:branch] || ''
310
310
  language
311
311
  mavenOpts
@@ -205,21 +205,31 @@ module JenkinsPipelineBuilder
205
205
  end
206
206
  end
207
207
 
208
- def publish_project(project_name, errors = {})
209
- job_collection.projects.each do |project|
210
- next unless project_name.nil? || project[:name] == project_name
211
- success, payload = resolve_project(project)
212
- if success
213
- logger.info 'successfully resolved project'
214
- compiled_project = payload
215
- else
216
- return { project_name: 'Failed to resolve' }
217
- end
208
+ def create_jobs_and_views(project)
209
+ success, payload = resolve_project(project)
210
+ if success
211
+ logger.info 'successfully resolved project'
212
+ compiled_project = payload
213
+ else
214
+ return { project_name: 'Failed to resolve' }
215
+ end
218
216
 
219
- errors = publish_jobs(compiled_project[:value][:jobs]) if compiled_project[:value][:jobs]
220
- next unless compiled_project[:value][:views]
221
- create_views compiled_project[:value][:views]
217
+ errors = publish_jobs(compiled_project[:value][:jobs]) if compiled_project[:value][:jobs]
218
+ return errors unless compiled_project[:value][:views]
219
+ create_views compiled_project[:value][:views]
220
+ errors
221
+ end
222
+
223
+ def publish_project(project_name)
224
+ return {} if project_name.nil?
225
+ errors = {}
226
+ found = false
227
+ job_collection.projects.each do |project|
228
+ next unless project[:name] == project_name
229
+ found = true
230
+ errors = create_jobs_and_views(project)
222
231
  end
232
+ fail "Project #{project_name} not found!" unless found
223
233
  errors
224
234
  end
225
235
 
@@ -21,5 +21,5 @@
21
21
  #
22
22
 
23
23
  module JenkinsPipelineBuilder
24
- VERSION = '0.11.2'
24
+ VERSION = '0.12.0'
25
25
  end
@@ -205,7 +205,8 @@ describe 'job_attributes' do
205
205
  remote_name: :foo,
206
206
  refspec: :refspec,
207
207
  remote_url: :remote_url,
208
- credentials_id: :creds
208
+ credentials_id: :creds,
209
+ skip_tag: true
209
210
  },
210
211
  scm_url: 'http://foo.com'
211
212
  }
@@ -238,6 +239,7 @@ describe 'job_attributes' do
238
239
  expect(scm_config.css('includedRegions').first.content).to eq 'included_region'
239
240
  expect(scm_config.css('excludedRegions').first.content).to eq 'excluded_region'
240
241
  expect(scm_config.css('credentialsId').first.content).to eq 'creds'
242
+ expect(scm_config.css('skipTag').first.content).to eq 'true'
241
243
  end
242
244
  end
243
245
 
@@ -69,6 +69,26 @@ describe 'publishers' do
69
69
  root_pom = sonar_nodes.select { |node| node.name == 'rootPom' }
70
70
  expect(root_pom.first.content).to match 'project_war/pom.xml'
71
71
  end
72
+
73
+ it 'populates the jdk by with default' do
74
+ params = { publishers: { sonar_result: {} } }
75
+
76
+ JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
77
+
78
+ sonar_nodes = @n_xml.root.children.first.children
79
+ root_pom = sonar_nodes.select { |node| node.name == 'jdk' }
80
+ expect(root_pom.first.content).to match '(Inherit From Job)'
81
+ end
82
+
83
+ it 'populates the jdk by' do
84
+ params = { publishers: { sonar_result: { jdk: 'java8' } } }
85
+
86
+ JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
87
+
88
+ sonar_nodes = @n_xml.root.children.first.children
89
+ root_pom = sonar_nodes.select { |node| node.name == 'jdk' }
90
+ expect(root_pom.first.content).to match 'java8'
91
+ end
72
92
  end
73
93
 
74
94
  context 'description_setter' do
@@ -38,7 +38,8 @@ BUILDERS = {
38
38
  maven3: ['0'],
39
39
  multi_job: ['0'],
40
40
  remote_job: ['0'],
41
- shell_command: ['0']
41
+ shell_command: ['0'],
42
+ checkmarx_scan: ['0']
42
43
  }
43
44
  TRIGGERS = {
44
45
  git_push: ['0'],
@@ -68,6 +68,10 @@ describe JenkinsPipelineBuilder::Generator do
68
68
  File.expand_path("../fixtures/generator_tests/#{fixture}", __FILE__)
69
69
  end
70
70
 
71
+ it 'raises an error when a specified project does not exist' do
72
+ expect { bootstrap(fixture_path('sample_pipeline'), 'Nopers') }.to raise_error
73
+ end
74
+
71
75
  it 'produces no errors while creating pipeline SamplePipeline with view' do
72
76
  errors = bootstrap(fixture_path('sample_pipeline'), 'SamplePipeline')
73
77
  expect(errors).to be_empty
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.11.2
4
+ version: 0.12.0
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-05-30 00:00:00.000000000 Z
12
+ date: 2015-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri