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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +28 -43
- data/{spec/unit_tests/spec_helper.rb → .simplecov} +2 -15
- data/README.md +66 -11
- data/Rakefile +1 -25
- data/bin/generate +0 -1
- data/jenkins_pipeline_builder.gemspec +6 -6
- data/lib/jenkins_pipeline_builder.rb +14 -8
- data/lib/jenkins_pipeline_builder/builders.rb +207 -155
- data/lib/jenkins_pipeline_builder/cli/base.rb +1 -1
- data/lib/jenkins_pipeline_builder/cli/describe.rb +12 -8
- data/lib/jenkins_pipeline_builder/cli/list.rb +7 -7
- data/lib/jenkins_pipeline_builder/compiler.rb +62 -49
- data/lib/jenkins_pipeline_builder/extensions.rb +108 -0
- data/lib/jenkins_pipeline_builder/generator.rb +209 -160
- data/lib/jenkins_pipeline_builder/job_builder.rb +174 -105
- data/lib/jenkins_pipeline_builder/module_registry.rb +43 -59
- data/lib/jenkins_pipeline_builder/publishers.rb +166 -93
- data/lib/jenkins_pipeline_builder/pull_request.rb +7 -7
- data/lib/jenkins_pipeline_builder/triggers.rb +63 -40
- data/lib/jenkins_pipeline_builder/utils.rb +10 -10
- data/lib/jenkins_pipeline_builder/version.rb +1 -1
- data/lib/jenkins_pipeline_builder/view.rb +94 -123
- data/lib/jenkins_pipeline_builder/wrappers.rb +163 -96
- data/spec/lib/jenkins_pipeline_builder/compiler_spec.rb +31 -0
- data/spec/lib/jenkins_pipeline_builder/extensions_spec.rb +145 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-10-SampleJob.yaml +2 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-40-PullRequestGenerator.yaml +12 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/project.yaml +12 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/SamplePipeline-10-Commit.yaml +3 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/SamplePipeline-20-Acceptance.yaml +3 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/SamplePipeline-30-Release.yaml +3 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/project.yaml +12 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/view.yaml +5 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/template_pipeline/jobs.tar.gz +0 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/template_pipeline/project.yaml +15 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/test_job.xml +48 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/view_test/duplicate_view.yaml +4 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/view_test/parent_view.yaml +9 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/view_test/regular_view.yaml +5 -0
- data/spec/lib/jenkins_pipeline_builder/generator_spec.rb +165 -0
- data/spec/lib/jenkins_pipeline_builder/module_registry_spec.rb +147 -0
- data/spec/lib/jenkins_pipeline_builder/pull_request_spec.rb +47 -0
- data/spec/lib/jenkins_pipeline_builder/spec_helper.rb +25 -0
- data/spec/lib/jenkins_pipeline_builder/utils_spec.rb +22 -0
- data/spec/lib/jenkins_pipeline_builder/view_spec.rb +54 -0
- metadata +54 -136
- data/lib/jenkins_pipeline_builder/extendable.rb +0 -42
- data/lib/jenkins_pipeline_builder/xml_helper.rb +0 -40
- data/spec/func_tests/spec_helper.rb +0 -18
- data/spec/func_tests/view_spec.rb +0 -90
- data/spec/unit_tests/compiler_spec.rb +0 -20
- data/spec/unit_tests/fixtures/files/Job-Build-Flow.xml +0 -57
- data/spec/unit_tests/fixtures/files/Job-Build-Flow.yaml +0 -22
- data/spec/unit_tests/fixtures/files/Job-Build-Maven.xml +0 -129
- data/spec/unit_tests/fixtures/files/Job-Build-Maven.yaml +0 -31
- data/spec/unit_tests/fixtures/files/Job-DSL.yaml +0 -14
- data/spec/unit_tests/fixtures/files/Job-DSL1.xml +0 -27
- data/spec/unit_tests/fixtures/files/Job-DSL2.xml +0 -25
- data/spec/unit_tests/fixtures/files/Job-Gem-Build.xml +0 -142
- data/spec/unit_tests/fixtures/files/Job-Gem-Build.yaml +0 -43
- data/spec/unit_tests/fixtures/files/Job-Generate-From-Template.xml +0 -32
- data/spec/unit_tests/fixtures/files/Job-Generate-From-Template.yaml +0 -8
- data/spec/unit_tests/fixtures/files/Job-Multi-Project.xml +0 -134
- data/spec/unit_tests/fixtures/files/Job-Multi-Project.yaml +0 -49
- data/spec/unit_tests/fixtures/files/archive_artifact.xml +0 -23
- data/spec/unit_tests/fixtures/files/archive_artifact.yaml +0 -5
- data/spec/unit_tests/fixtures/files/choice_parameter.xml +0 -39
- data/spec/unit_tests/fixtures/files/choice_parameter.yaml +0 -14
- data/spec/unit_tests/fixtures/files/concurrent_build.xml +0 -17
- data/spec/unit_tests/fixtures/files/concurrent_build.yaml +0 -4
- data/spec/unit_tests/fixtures/files/copy_artifact.xml +0 -30
- data/spec/unit_tests/fixtures/files/copy_artifact.yaml +0 -14
- data/spec/unit_tests/fixtures/files/discard_old.xml +0 -17
- data/spec/unit_tests/fixtures/files/discard_old.yaml +0 -8
- data/spec/unit_tests/fixtures/files/downstream.xml +0 -36
- data/spec/unit_tests/fixtures/files/downstream.yaml +0 -13
- data/spec/unit_tests/fixtures/files/downstream_blocking.xml +0 -19
- data/spec/unit_tests/fixtures/files/downstream_blocking.yaml +0 -15
- data/spec/unit_tests/fixtures/files/git_include_exclude.xml +0 -53
- data/spec/unit_tests/fixtures/files/git_include_exclude.yaml +0 -8
- data/spec/unit_tests/fixtures/files/groovy_postbuild.xml +0 -29
- data/spec/unit_tests/fixtures/files/groovy_postbuild.yaml +0 -9
- data/spec/unit_tests/fixtures/files/periodic_build.xml +0 -21
- data/spec/unit_tests/fixtures/files/periodic_build.yaml +0 -5
- data/spec/unit_tests/fixtures/files/post_build_script.xml +0 -28
- data/spec/unit_tests/fixtures/files/post_build_script.yaml +0 -11
- data/spec/unit_tests/fixtures/files/prepare_environment.xml +0 -17
- data/spec/unit_tests/fixtures/files/prepare_environment.yaml +0 -7
- data/spec/unit_tests/fixtures/files/project.yaml +0 -15
- data/spec/unit_tests/fixtures/files/properties_file.xml +0 -27
- data/spec/unit_tests/fixtures/files/properties_file.yaml +0 -8
- data/spec/unit_tests/fixtures/files/remote_job.xml +0 -18
- data/spec/unit_tests/fixtures/files/remote_job.yaml +0 -19
- data/spec/unit_tests/fixtures/files/rvm05.xml +0 -26
- data/spec/unit_tests/fixtures/files/rvm05.yaml +0 -5
- data/spec/unit_tests/fixtures/files/specific_priority.xml +0 -22
- data/spec/unit_tests/fixtures/files/specific_priority.yaml +0 -6
- data/spec/unit_tests/fixtures/files/throttle.xml +0 -17
- data/spec/unit_tests/fixtures/files/throttle.yaml +0 -8
- data/spec/unit_tests/fixtures/files/upstream.xml +0 -17
- data/spec/unit_tests/fixtures/files/upstream.yaml +0 -7
- data/spec/unit_tests/fixtures/pull_request/00.yaml +0 -14
- data/spec/unit_tests/fixtures/pull_request/10.yaml +0 -7
- data/spec/unit_tests/fixtures/pull_request/11.yaml +0 -4
- data/spec/unit_tests/fixtures/pull_request/project.yaml +0 -11
- data/spec/unit_tests/fixtures/templates/external_job.yaml +0 -4
- data/spec/unit_tests/fixtures/templates/project_with_jobs.yaml +0 -25
- data/spec/unit_tests/generator_spec.rb +0 -94
- data/spec/unit_tests/module_registry_spec.rb +0 -16
- data/spec/unit_tests/resolve_dependencies_spec.rb +0 -266
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7732d073bba8e738befc23bd6c71249ccbf23ff5
|
4
|
+
data.tar.gz: 122b6fe751d205a6b108fab75ac549efa987444f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a880f17364c6d7a44aefd11f6cadabb9b4aaf8107d539accc2c81ffd61c9cc33dafe277d2508e5d463c11b062ae88fc83708f7920aad5f360163fefd9631609
|
7
|
+
data.tar.gz: b0e8b310565ba4327071029011a7a734d9383c04a1275a2587d753a70715cb5385355bbb7354233c71e93157b9eebcc9843ed078f37fd191c541b366a1ad2ee9
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -7,63 +7,48 @@
|
|
7
7
|
|
8
8
|
#######
|
9
9
|
# WIP
|
10
|
-
|
11
|
-
|
12
|
-
Enabled: false
|
13
|
-
Max: 120
|
14
|
-
|
15
|
-
# Offense count: 8
|
16
|
-
# Configuration parameters: CountComments.
|
17
|
-
Style/MethodLength:
|
18
|
-
Enabled: false
|
19
|
-
Max: 30
|
10
|
+
Style/CyclomaticComplexity:
|
11
|
+
Max: 9
|
20
12
|
|
21
13
|
########
|
22
14
|
# Fix these later
|
23
|
-
# Offense count: 1
|
24
|
-
Lint/Eval:
|
25
|
-
Enabled: false
|
26
|
-
|
27
|
-
# Offense count: 6
|
28
|
-
Lint/ShadowingOuterLocalVariable:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
# Offense count: 2
|
32
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
33
|
-
Style/ClassAndModuleChildren:
|
34
|
-
Enabled: false
|
35
|
-
|
36
|
-
# Offense count: 6
|
37
15
|
# Configuration parameters: CountComments.
|
38
16
|
Style/ClassLength:
|
39
|
-
Enabled: false
|
40
|
-
Max:
|
41
|
-
|
42
|
-
# Offense count: 12
|
43
|
-
Style/CyclomaticComplexity:
|
44
|
-
Max: 20
|
17
|
+
#Enabled: false
|
18
|
+
Max: 500
|
45
19
|
|
46
|
-
|
47
|
-
|
48
|
-
Enabled: false
|
20
|
+
#######
|
21
|
+
# Finalized settings
|
49
22
|
|
50
|
-
Style/
|
51
|
-
|
23
|
+
Style/LineLength:
|
24
|
+
Max: 120
|
25
|
+
Exclude:
|
26
|
+
- 'spec/lib/jenkins_pipeline_builder/compiler_spec.rb'
|
27
|
+
- 'spec/lib/jenkins_pipeline_builder/view_spec.rb'
|
28
|
+
- 'spec/lib/jenkins_pipeline_builder/pull_request_spec.rb'
|
52
29
|
|
53
|
-
|
54
|
-
|
30
|
+
# Configuration parameters: CountComments.
|
31
|
+
Style/MethodLength:
|
32
|
+
Max: 25
|
55
33
|
|
56
|
-
|
57
|
-
Lint/UselessSetterCall:
|
34
|
+
Style/Documentation:
|
58
35
|
Enabled: false
|
59
36
|
|
60
|
-
# Offense count: 9
|
61
37
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
62
38
|
Style/Next:
|
63
|
-
|
39
|
+
Exclude:
|
40
|
+
- 'lib/jenkins_pipeline_builder/publishers.rb'
|
41
|
+
- 'lib/jenkins_pipeline_builder/triggers.rb'
|
42
|
+
- 'lib/jenkins_pipeline_builder/wrappers.rb'
|
43
|
+
- 'lib/jenkins_pipeline_builder/builders.rb'
|
44
|
+
- 'lib/jenkins_pipeline_builder/job_builder.rb'
|
64
45
|
|
65
|
-
# Offense count: 7
|
66
46
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
67
47
|
Style/VariableName:
|
68
|
-
|
48
|
+
Exclude:
|
49
|
+
- 'lib/jenkins_pipeline_builder/publishers.rb'
|
50
|
+
- 'lib/jenkins_pipeline_builder/triggers.rb'
|
51
|
+
- 'lib/jenkins_pipeline_builder/wrappers.rb'
|
52
|
+
- 'lib/jenkins_pipeline_builder/builders.rb'
|
53
|
+
- 'lib/jenkins_pipeline_builder/job_builder.rb'
|
69
54
|
#######
|
@@ -1,12 +1,7 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require 'rspec'
|
3
|
-
|
4
|
-
require 'simplecov'
|
5
1
|
require 'simplecov-rcov'
|
6
|
-
require 'webmock/rspec'
|
7
|
-
|
8
2
|
SimpleCov.profiles.define 'spec' do
|
9
3
|
add_group 'jenkins_pipeline_builder', '/lib/'
|
4
|
+
add_filter 'spec'
|
10
5
|
coverage_dir 'out/coverage'
|
11
6
|
formatter SimpleCov::Formatter::MultiFormatter[
|
12
7
|
SimpleCov::Formatter::Console,
|
@@ -20,13 +15,5 @@ class SimpleCov::Formatter::Console
|
|
20
15
|
end
|
21
16
|
end
|
22
17
|
|
23
|
-
SimpleCov.start 'spec' #
|
24
|
-
|
25
|
-
require File.expand_path('../../../lib/jenkins_pipeline_builder', __FILE__)
|
26
|
-
require 'rspec/matchers'
|
27
|
-
require 'equivalent-xml'
|
18
|
+
SimpleCov.start 'spec' #if ENV["COVERAGE"]
|
28
19
|
|
29
|
-
RSpec.configure do |config|
|
30
|
-
config.before(:each) do
|
31
|
-
end
|
32
|
-
end
|
data/README.md
CHANGED
@@ -169,7 +169,6 @@ Here's a high level overview of what's available:
|
|
169
169
|
- params: |
|
170
170
|
param1
|
171
171
|
param2
|
172
|
-
condition: FAILURE
|
173
172
|
trigger_with_no_parameters: false
|
174
173
|
# Below is Optional, values can be SUCCESS, FAILURE, UNSTABLE, never
|
175
174
|
fail: FAILURE # Fail this build step if the triggered build is worse or equal to
|
@@ -251,6 +250,10 @@ Here's a high level overview of what's available:
|
|
251
250
|
exclude: '' # Optional, exclude string/pattern
|
252
251
|
latest_only: false # Optional, true or false, defaults to false
|
253
252
|
allow_empty: false # Optional, true or false, defaults to false
|
253
|
+
- email_notifications:
|
254
|
+
recipients: 'test@example.com' # Whitepace-delimited list of recipients
|
255
|
+
send_if_unstable: false # Optional, default to true
|
256
|
+
send_to_individuals: true # Optional, default to false
|
254
257
|
triggers:
|
255
258
|
- git_push: true
|
256
259
|
- scm_polling: 'H/5 * * * *'
|
@@ -330,25 +333,77 @@ If a set of Defaults is specified with the name global, that will be used by all
|
|
330
333
|
param1: 'value 1'
|
331
334
|
```
|
332
335
|
|
336
|
+
Extending the Pipeline Builder
|
337
|
+
------------------------------
|
338
|
+
|
339
|
+
Have a feature you want to test out before adding it to the source? Now you can create a quick "extension" to the pipeline builder to add new or overwrite existing functionality.
|
340
|
+
|
341
|
+
To add an extension, create an "extensions" directiroy inside of "pipeline" and create a file named "myExtension.rb" (or any name). Use `JenkinsPipelineBuilder.extend` to register your extension.
|
342
|
+
|
343
|
+
When registering, you must use one of the following register methods, depending on what category your change falls into:
|
344
|
+
* register_job_attribute
|
345
|
+
* register_builder
|
346
|
+
* register_publisher
|
347
|
+
* register_wrapper
|
348
|
+
* register_trigger
|
349
|
+
|
350
|
+
For help figuring out what category your change is, examine the config.xml for a job that uses your feature. If it is a first child of the root "project" node, your change is a job_attribute. Otherwise it should be either a builder, publisher, wrapper, or trigger, depending what child node it is found in the XML tree.
|
351
|
+
|
352
|
+
Here is an example of extending the pipeline builder with a new publisher:
|
353
|
+
|
354
|
+
```ruby
|
355
|
+
JenkinsPipelineBuilder.extend do |registry|
|
356
|
+
registry.register_publisher :yaml_name, "Jenkins UI Name", "Description of this feature" { |params, xml| apply_extension(params, xml) }
|
357
|
+
|
358
|
+
def apply_extension(params, xml)
|
359
|
+
xml.send("new_element") {
|
360
|
+
xml.property params[:value]
|
361
|
+
}
|
362
|
+
end
|
363
|
+
end
|
364
|
+
```
|
365
|
+
|
366
|
+
OR
|
367
|
+
|
368
|
+
```ruby
|
369
|
+
JenkinsPipelineBuilder.extend do |registry|
|
370
|
+
registry.register_publisher :yaml_name, "Jenkins UI Name", "Description of this feature" do |params, xml|
|
371
|
+
xml.send("new_element") {
|
372
|
+
xml.property params[:value]
|
373
|
+
}
|
374
|
+
end
|
375
|
+
end
|
376
|
+
```
|
377
|
+
|
378
|
+
Finally, you can add the new DSL in your YAML:
|
379
|
+
|
380
|
+
```yaml
|
381
|
+
- job:
|
382
|
+
name: 'Example-Job'
|
383
|
+
publishers:
|
384
|
+
- yaml_name:
|
385
|
+
value: 'example'
|
386
|
+
```
|
387
|
+
|
333
388
|
PLUGINS:
|
334
389
|
--------
|
335
390
|
|
336
391
|
A number of the DSL options rely on Jenkins plugins, including:
|
337
392
|
|
338
|
-
* ansicolor - "AnsiColor"
|
393
|
+
* ansicolor - "AnsiColor"
|
339
394
|
* (view) type: 'categorizedView' - "categorized-view"
|
340
|
-
* hipchat - "HipChat Plugin"
|
341
|
-
* inject_env_vars - "Environment Injector Plugin"
|
342
|
-
* priority - "Priority Sorter plugin"
|
343
|
-
* downstream - "Parameterized Trigger plugin"
|
344
|
-
* rvm - "Rvm"
|
345
|
-
* throttle - "Throttle Concurrent Builds Plug-in"
|
346
|
-
* timestamp - "Timestamper"
|
347
|
-
* groovy_postbuild - "Groovy Postbuild"
|
395
|
+
* hipchat - "HipChat Plugin"
|
396
|
+
* inject_env_vars - "Environment Injector Plugin"
|
397
|
+
* priority - "Priority Sorter plugin"
|
398
|
+
* downstream - "Parameterized Trigger plugin"
|
399
|
+
* rvm - "Rvm"
|
400
|
+
* throttle - "Throttle Concurrent Builds Plug-in"
|
401
|
+
* timestamp - "Timestamper"
|
402
|
+
* groovy_postbuild - "Groovy Postbuild"
|
348
403
|
|
349
404
|
Just about every plugin above can be installed through Jenkins (Manage Jenkins > Manage Plugins > Available)
|
350
405
|
|
351
|
-
|
406
|
+
For a list of all currently supported plugins run `generate list` or `generate list type` to see all of a specific type
|
352
407
|
|
353
408
|
CONTRIBUTING:
|
354
409
|
----------------
|
data/Rakefile
CHANGED
@@ -26,31 +26,7 @@ require 'rubocop/rake_task'
|
|
26
26
|
|
27
27
|
RuboCop::RakeTask.new
|
28
28
|
|
29
|
-
RSpec::Core::RakeTask.new
|
30
|
-
spec.pattern = '.spec/**/*_spec.rb'
|
31
|
-
spec.verbose = true
|
32
|
-
spec.fail_on_error = false
|
33
|
-
spec.rspec_opts = spec_output 'spec.xml'
|
34
|
-
end
|
35
|
-
|
36
|
-
def spec_output(filename)
|
37
|
-
"--color --format documentation --format RspecJunitFormatter --out out/#{filename}"
|
38
|
-
end
|
39
|
-
|
40
|
-
RSpec::Core::RakeTask.new(:unit_tests) do |spec|
|
41
|
-
spec.pattern = FileList['spec/unit_tests/*_spec.rb']
|
42
|
-
spec.rspec_opts = ['--color', '--format documentation']
|
43
|
-
end
|
44
|
-
|
45
|
-
RSpec::Core::RakeTask.new(:func_tests) do |spec|
|
46
|
-
spec.pattern = FileList['spec/func_tests/*_spec.rb']
|
47
|
-
spec.rspec_opts = ['--color', '--format documentation']
|
48
|
-
end
|
49
|
-
|
50
|
-
RSpec::Core::RakeTask.new(:test) do |spec|
|
51
|
-
spec.pattern = FileList['spec/*/*.rb']
|
52
|
-
spec.rspec_opts = ['--color', '--format documentation']
|
53
|
-
end
|
29
|
+
RSpec::Core::RakeTask.new
|
54
30
|
|
55
31
|
YARD::Config.load_plugin 'thor'
|
56
32
|
YARD::Rake::YardocTask.new do |t|
|
data/bin/generate
CHANGED
@@ -19,7 +19,6 @@
|
|
19
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
# THE SOFTWARE.
|
22
|
-
#
|
23
22
|
|
24
23
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
25
24
|
require 'jenkins_pipeline_builder'
|
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = JenkinsPipelineBuilder::VERSION
|
9
9
|
spec.authors = ['Igor Moochnick', 'Joseph Henrich']
|
10
10
|
spec.email = %w(igor.moochnick@gmail.com crimsonknave@gmail.com)
|
11
|
-
spec.description =
|
12
|
-
automating Job & Pipeline creation from the YAML files checked-in with your application source code
|
13
|
-
spec.summary =
|
11
|
+
spec.description = 'This is a simple and easy-to-use Jenkins Pipeline generator with features focused on
|
12
|
+
automating Job & Pipeline creation from the YAML files checked-in with your application source code'
|
13
|
+
spec.summary = 'This gem is will boostrap your Jenkins pipelines'
|
14
14
|
spec.homepage = 'https://github.com/ConstantContact/jenkins_pipeline_builder'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
@@ -21,15 +21,15 @@ automating Job & Pipeline creation from the YAML files checked-in with your appl
|
|
21
21
|
|
22
22
|
ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] = 'true'
|
23
23
|
|
24
|
-
spec.add_dependency 'nokogiri', '~> 1.
|
25
|
-
spec.add_dependency 'jenkins_api_client', '~> 0.
|
24
|
+
spec.add_dependency 'nokogiri', '~> 1.6.0'
|
25
|
+
spec.add_dependency 'jenkins_api_client', '~> 1.0.0'
|
26
26
|
spec.add_dependency 'thor', '>= 0.18.0'
|
27
27
|
spec.add_dependency 'activesupport'
|
28
28
|
spec.add_dependency 'archive-tar-minitar'
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
31
31
|
spec.add_development_dependency 'rake'
|
32
|
-
spec.add_development_dependency 'rspec', '~>
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
33
|
spec.add_development_dependency 'bump'
|
34
34
|
spec.add_development_dependency 'json'
|
35
35
|
spec.add_development_dependency 'gem-release'
|
@@ -25,8 +25,6 @@ require 'active_support/core_ext'
|
|
25
25
|
|
26
26
|
require 'jenkins_pipeline_builder/version'
|
27
27
|
require 'jenkins_pipeline_builder/utils'
|
28
|
-
require 'jenkins_pipeline_builder/xml_helper'
|
29
|
-
require 'jenkins_pipeline_builder/extendable'
|
30
28
|
require 'jenkins_pipeline_builder/compiler'
|
31
29
|
require 'jenkins_pipeline_builder/module_registry'
|
32
30
|
require 'jenkins_pipeline_builder/pull_request'
|
@@ -48,18 +46,26 @@ module JenkinsPipelineBuilder
|
|
48
46
|
@credentials
|
49
47
|
end
|
50
48
|
|
49
|
+
def logger
|
50
|
+
@_client.logger
|
51
|
+
end
|
52
|
+
|
51
53
|
def registry
|
52
54
|
generator.module_registry
|
53
55
|
end
|
56
|
+
|
57
|
+
def load_registry
|
58
|
+
load 'jenkins_pipeline_builder/builders.rb'
|
59
|
+
load 'jenkins_pipeline_builder/job_builder.rb'
|
60
|
+
load 'jenkins_pipeline_builder/wrappers.rb'
|
61
|
+
load 'jenkins_pipeline_builder/publishers.rb'
|
62
|
+
load 'jenkins_pipeline_builder/triggers.rb'
|
63
|
+
end
|
54
64
|
end
|
55
65
|
end
|
56
66
|
JenkinsPipelineBuilder.generator
|
57
|
-
require 'jenkins_pipeline_builder/
|
58
|
-
|
59
|
-
require 'jenkins_pipeline_builder/wrappers'
|
60
|
-
require 'jenkins_pipeline_builder/publishers'
|
61
|
-
require 'jenkins_pipeline_builder/triggers'
|
62
|
-
|
67
|
+
require 'jenkins_pipeline_builder/extensions'
|
68
|
+
JenkinsPipelineBuilder.load_registry
|
63
69
|
require 'jenkins_pipeline_builder/cli/helper'
|
64
70
|
require 'jenkins_pipeline_builder/cli/view'
|
65
71
|
require 'jenkins_pipeline_builder/cli/pipeline'
|
@@ -18,207 +18,259 @@
|
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
22
|
+
builder do
|
23
|
+
name :multi_job
|
24
|
+
plugin_id 123
|
25
|
+
min_version 0
|
26
|
+
announced false
|
27
|
+
|
28
|
+
xml do |params|
|
29
|
+
params[:phases].each do |name, content|
|
30
|
+
send('com.tikal.jenkins.plugins.multijob.MultiJobBuilder') do
|
31
|
+
phaseName name
|
32
|
+
phaseJobs do
|
33
|
+
content[:jobs].each do |job|
|
34
|
+
send('com.tikal.jenkins.plugins.multijob.PhaseJobsConfig') do
|
35
|
+
jobName job[:name]
|
36
|
+
currParams job[:current_params] || false
|
37
|
+
exposedSCM job[:exposed_scm] || false
|
38
|
+
if job[:config]
|
39
|
+
configs do
|
40
|
+
if job[:config].key? :predefined_build_parameters
|
41
|
+
send('hudson.plugins.parameterizedtrigger.PredefinedBuildParameters') do
|
42
|
+
properties job[:config][:predefined_build_parameters].join "\n"
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
47
|
-
xml.continuationCondition content[:continue_condition] || 'SUCCESSFUL'
|
48
49
|
end
|
50
|
+
continuationCondition content[:continue_condition] || 'SUCCESSFUL'
|
49
51
|
end
|
50
52
|
end
|
53
|
+
end
|
54
|
+
end
|
51
55
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
builder do
|
57
|
+
name :maven3
|
58
|
+
plugin_id 123
|
59
|
+
min_version 0
|
60
|
+
announced false
|
61
|
+
|
62
|
+
xml do |params|
|
63
|
+
send('org.jfrog.hudson.maven3.Maven3Builder') do
|
64
|
+
mavenName params[:mavenName] || 'tools-maven-3.0.3'
|
65
|
+
rootPom params[:rootPom]
|
66
|
+
goals params[:goals]
|
67
|
+
mavenOpts params[:options]
|
59
68
|
end
|
69
|
+
end
|
70
|
+
end
|
60
71
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
72
|
+
builder do
|
73
|
+
name :shell_command
|
74
|
+
plugin_id 123
|
75
|
+
min_version 0
|
76
|
+
announced false
|
77
|
+
|
78
|
+
xml do |param|
|
79
|
+
send('hudson.tasks.Shell') do
|
80
|
+
command param
|
65
81
|
end
|
82
|
+
end
|
83
|
+
end
|
66
84
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
85
|
+
builder do
|
86
|
+
name :inject_vars_file
|
87
|
+
plugin_id 123
|
88
|
+
min_version 0
|
89
|
+
announced false
|
90
|
+
|
91
|
+
xml do |params|
|
92
|
+
EnvInjectBuilder do
|
93
|
+
info do
|
94
|
+
propertiesFilePath params
|
72
95
|
end
|
73
96
|
end
|
97
|
+
end
|
98
|
+
end
|
74
99
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
100
|
+
builder do
|
101
|
+
name :blocking_downstream
|
102
|
+
plugin_id 123
|
103
|
+
min_version 0
|
104
|
+
announced false
|
80
105
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
106
|
+
xml do |params|
|
107
|
+
colors = {
|
108
|
+
'SUCCESS' => { ordinal: 0, color: 'BLUE' },
|
109
|
+
'FAILURE' => { ordinal: 2, color: 'RED' },
|
110
|
+
'UNSTABLE' => { ordinal: 1, color: 'YELLOW' }
|
111
|
+
}
|
112
|
+
send('hudson.plugins.parameterizedtrigger.TriggerBuilder', 'plugin' => 'parameterized-trigger') do
|
113
|
+
configs do
|
114
|
+
send('hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig') do
|
115
|
+
|
116
|
+
configs do
|
117
|
+
params[:data] = [{ params: '' }] unless params[:data]
|
118
|
+
params[:data].each do |config|
|
119
|
+
if config[:params]
|
120
|
+
send('hudson.plugins.parameterizedtrigger.PredefinedBuildParameters') do
|
121
|
+
properties config[:params]
|
88
122
|
end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
123
|
+
end
|
124
|
+
if config[:file]
|
125
|
+
send('hudson.plugins.parameterizedtrigger.FileBuildParameters') do
|
126
|
+
propertiesFile config[:file]
|
127
|
+
failTriggerOnMissing false
|
94
128
|
end
|
95
129
|
end
|
96
130
|
end
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
131
|
+
end
|
132
|
+
projects params[:project]
|
133
|
+
condition 'ALWAYS'
|
134
|
+
triggerWithNoParameters params[:trigger_with_no_parameters] || false
|
135
|
+
block do
|
136
|
+
if params[:fail] && colors.include?(params[:fail])
|
137
|
+
buildStepFailureThreshold do
|
138
|
+
name params[:fail]
|
139
|
+
ordinal colors[params[:fail]][:ordinal]
|
140
|
+
color colors[params[:fail]][:color]
|
141
|
+
completeBuild 'true'
|
108
142
|
end
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
143
|
+
end
|
144
|
+
if params[:mark_fail] && colors.include?(params[:mark_fail])
|
145
|
+
failureThreshold do
|
146
|
+
name params[:mark_fail]
|
147
|
+
ordinal colors[params[:mark_fail]][:ordinal]
|
148
|
+
color colors[params[:mark_fail]][:color]
|
149
|
+
completeBuild 'true'
|
116
150
|
end
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
151
|
+
end
|
152
|
+
if params[:mark_unstable] && colors.include?(params[:mark_unstable])
|
153
|
+
unstableThreshold do
|
154
|
+
name params[:mark_unstable]
|
155
|
+
ordinal colors[params[:mark_unstable]][:ordinal]
|
156
|
+
color colors[params[:mark_unstable]][:color]
|
157
|
+
completeBuild 'true'
|
124
158
|
end
|
125
159
|
end
|
126
|
-
xml.buildAllNodesWithLabel false
|
127
160
|
end
|
161
|
+
buildAllNodesWithLabel false
|
128
162
|
end
|
129
163
|
end
|
130
164
|
end
|
165
|
+
end
|
166
|
+
end
|
131
167
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
168
|
+
builder do
|
169
|
+
name :remote_job
|
170
|
+
plugin_id 123
|
171
|
+
min_version 0
|
172
|
+
announced false
|
173
|
+
|
174
|
+
xml do |params|
|
175
|
+
param_list = params[:parameters][:content].split("\n") if params[:parameters] && params[:parameters][:content]
|
176
|
+
send(
|
177
|
+
'org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration',
|
178
|
+
'plugin' => 'Parameterized-Remote-Trigger'
|
179
|
+
) do
|
180
|
+
remoteJenkinsName params[:server]
|
181
|
+
job params[:job_name]
|
182
|
+
shouldNotFailBuild params[:continue_on_remote_failure] if params[:continue_on_remote_failure]
|
183
|
+
pollInterval params[:polling_interval] if params[:polling_interval]
|
184
|
+
blockBuildUntilComplete params[:blocking] if params[:blocking]
|
185
|
+
token
|
186
|
+
if params[:parameters] && params[:parameters][:content]
|
187
|
+
parameters params[:parameters][:content]
|
188
|
+
parameterList do
|
189
|
+
param_list.each do |p|
|
190
|
+
string p
|
155
191
|
end
|
156
192
|
end
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
193
|
+
elsif params[:parameters] && params[:parameters][:file]
|
194
|
+
loadParamsFromFile 'true'
|
195
|
+
parameterFile params[:parameters][:file]
|
196
|
+
else
|
197
|
+
# This was here for some reason?
|
198
|
+
# parameters
|
199
|
+
parameterList do
|
200
|
+
string
|
201
|
+
end
|
202
|
+
end
|
203
|
+
if params[:credentials] && params[:credentials][:type]
|
204
|
+
overrideAuth 'true'
|
205
|
+
auth do
|
206
|
+
send('org.jenkinsci.plugins.ParameterizedRemoteTrigger.Auth') do
|
207
|
+
if params[:credentials][:type] == 'api_token'
|
208
|
+
authType 'apiToken'
|
209
|
+
username params[:credentials][:username]
|
210
|
+
API__TOKEN params[:credentials][:api_token]
|
211
|
+
else
|
212
|
+
authType 'none'
|
168
213
|
end
|
169
214
|
end
|
170
215
|
end
|
171
216
|
end
|
172
217
|
end
|
218
|
+
end
|
219
|
+
end
|
173
220
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
221
|
+
builder do
|
222
|
+
name :copy_artifact
|
223
|
+
plugin_id 123
|
224
|
+
min_version 0
|
225
|
+
announced false
|
226
|
+
|
227
|
+
xml do |params|
|
228
|
+
send('hudson.plugins.copyartifact.CopyArtifact', 'plugin' => 'copyartifact') do
|
229
|
+
project params[:project]
|
230
|
+
filter params[:artifacts]
|
231
|
+
target params[:target_directory]
|
232
|
+
parameters params[:filter] if params[:filter]
|
233
|
+
if params[:selector] && params[:selector][:type]
|
234
|
+
case params[:selector][:type]
|
235
|
+
when 'saved'
|
236
|
+
send('selector', 'class' => 'hudson.plugins.copyartifact.SavedBuildSelector')
|
237
|
+
when 'triggered'
|
238
|
+
send('selector', 'class' => 'hudson.plugins.copyartifact.TriggeredBuildSelector') do
|
239
|
+
fallbackToLastSuccessful params[:selector][:fallback] if params[:selector][:fallback]
|
240
|
+
end
|
241
|
+
when 'permalink'
|
242
|
+
send('selector', 'class' => 'hudson.plugins.copyartifact.PermalinkBuildSelector') do
|
243
|
+
id params[:selector][:id] if params[:selector][:id]
|
244
|
+
end
|
245
|
+
when 'specific'
|
246
|
+
send('selector', 'class' => 'hudson.plugins.copyartifact.SpecificBuildSelector') do
|
247
|
+
buildNumber params[:selector][:number] if params[:selector][:number]
|
248
|
+
end
|
249
|
+
when 'workspace'
|
250
|
+
send('selector', 'class' => 'hudson.plugins.copyartifact.WorkspaceSelector')
|
251
|
+
when 'parameter'
|
252
|
+
send('selector', 'class' => 'hudson.plugins.copyartifact.ParameterizedBuildSelector') do
|
253
|
+
parameterName params[:selector][:param] if params[:selector][:param]
|
206
254
|
end
|
207
255
|
else
|
208
|
-
|
256
|
+
send('selector', 'class' => 'hudson.plugins.copyartifact.StatusBuildSelector') do
|
257
|
+
stable params[:selector][:stable] if params[:selector][:stable]
|
258
|
+
end
|
209
259
|
end
|
210
|
-
|
211
|
-
|
260
|
+
else
|
261
|
+
send('selector', 'class' => 'hudson.plugins.copyartifact.StatusBuildSelector')
|
262
|
+
end
|
263
|
+
if params[:fingerprint].nil?
|
264
|
+
doNotFingerprintArtifacts false
|
265
|
+
else
|
266
|
+
if params[:fingerprint].to_s == 'true'
|
267
|
+
doNotFingerprintArtifacts false
|
212
268
|
else
|
213
|
-
|
214
|
-
xml.doNotFingerprintArtifacts false
|
215
|
-
else
|
216
|
-
xml.doNotFingerprintArtifacts true
|
217
|
-
end
|
269
|
+
doNotFingerprintArtifacts true
|
218
270
|
end
|
219
|
-
xml.flatten true if params[:flatten]
|
220
|
-
xml.optional true if params[:optional]
|
221
271
|
end
|
272
|
+
flatten true if params[:flatten]
|
273
|
+
optional true if params[:optional]
|
222
274
|
end
|
223
275
|
end
|
224
276
|
end
|