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
@@ -20,126 +20,193 @@
|
|
20
20
|
# THE SOFTWARE.
|
21
21
|
#
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
wrapper do
|
24
|
+
name :ansicolor
|
25
|
+
plugin_id 123
|
26
|
+
min_version 0
|
27
|
+
announced false
|
28
|
+
jenkins_name 'color ansi'
|
29
|
+
description 'this is a description'
|
30
|
+
xml do |_|
|
31
|
+
send('hudson.plugins.ansicolor.AnsiColorBuildWrapper') do
|
32
|
+
colorMapName 'xterm'
|
29
33
|
end
|
34
|
+
end
|
35
|
+
end
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
wrapper do
|
38
|
+
name :timestamp
|
39
|
+
plugin_id 123
|
40
|
+
min_version 0
|
41
|
+
announced false
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
43
|
+
xml do |_|
|
44
|
+
send('hudson.plugins.timestamper.TimestamperBuildWrapper', 'plugin' => 'timestamper')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
wrapper do
|
49
|
+
name :rvm
|
50
|
+
plugin_id 123
|
51
|
+
min_version '0.5'
|
52
|
+
announced false
|
53
|
+
description 'rvm plugin for versions 0.5 and greater'
|
54
|
+
|
55
|
+
xml do |wrapper|
|
56
|
+
send('ruby-proxy-object') do
|
57
|
+
send('ruby-object', 'ruby-class' => 'Jenkins::Tasks::BuildWrapperProxy', 'pluginid' => 'rvm') do
|
58
|
+
object('ruby-class' => 'RvmWrapper', 'pluginid' => 'rvm') do
|
59
|
+
impl('pluginid' => 'rvm', 'ruby-class' => 'String') { text wrapper }
|
42
60
|
end
|
61
|
+
pluginid(:pluginid => 'rvm', 'ruby-class' => 'String') { text 'rvm' }
|
43
62
|
end
|
44
63
|
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
wrapper do
|
68
|
+
name :name
|
69
|
+
plugin_id 123
|
70
|
+
min_version 0
|
71
|
+
announced false
|
72
|
+
|
73
|
+
xml do |_|
|
74
|
+
end
|
75
|
+
end
|
45
76
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
77
|
+
wrapper do
|
78
|
+
name :rvm
|
79
|
+
plugin_id 123
|
80
|
+
min_version '0'
|
81
|
+
announced false
|
82
|
+
description 'rvm plugin for versions less than 0.5'
|
83
|
+
|
84
|
+
xml do |wrapper|
|
85
|
+
send('ruby-proxy-object') do
|
86
|
+
send('ruby-object', 'ruby-class' => 'Jenkins::Plugin::Proxies::BuildWrapper', 'pluginid' => 'rvm') do
|
87
|
+
object('ruby-class' => 'RvmWrapper', 'pluginid' => 'rvm') do
|
88
|
+
impl('pluginid' => 'rvm', 'ruby-class' => 'String') do
|
89
|
+
text wrapper
|
51
90
|
end
|
52
|
-
xml.pluginid(:pluginid => 'rvm', 'ruby-class' => 'String') { xml.text 'rvm' }
|
53
91
|
end
|
92
|
+
pluginid(:pluginid => 'rvm', 'ruby-class' => 'String') { text 'rvm' }
|
54
93
|
end
|
55
94
|
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
wrapper do
|
99
|
+
name :inject_passwords
|
100
|
+
plugin_id 123
|
101
|
+
min_version 0
|
102
|
+
announced false
|
56
103
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
104
|
+
xml do |passwords|
|
105
|
+
EnvInjectPasswordWrapper do
|
106
|
+
injectGlobalPasswords false
|
107
|
+
passwordEntries do
|
108
|
+
passwords.each do |password|
|
109
|
+
EnvInjectPasswordEntry do
|
110
|
+
name password[:name]
|
111
|
+
value password[:value]
|
66
112
|
end
|
67
113
|
end
|
68
114
|
end
|
69
115
|
end
|
116
|
+
end
|
117
|
+
end
|
70
118
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
119
|
+
wrapper do
|
120
|
+
name :inject_env_var
|
121
|
+
plugin_id 123
|
122
|
+
min_version 0
|
123
|
+
announced false
|
124
|
+
|
125
|
+
xml do |params|
|
126
|
+
EnvInjectBuildWrapper do
|
127
|
+
info do
|
128
|
+
propertiesFilePath params[:file] if params[:file]
|
129
|
+
propertiesContent params[:content] if params[:content]
|
130
|
+
loadFilesFromMaster false
|
78
131
|
end
|
79
132
|
end
|
133
|
+
end
|
134
|
+
end
|
80
135
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
xml.envVarsPatterns do
|
95
|
-
xml.includePatterns
|
96
|
-
xml.excludePatterns '*password*,*secret*'
|
97
|
-
end
|
98
|
-
xml.discardOldBuilds false
|
99
|
-
xml.discardBuildArtifacts true
|
136
|
+
wrapper do
|
137
|
+
name :artifactory
|
138
|
+
plugin_id 123
|
139
|
+
min_version 0
|
140
|
+
announced false
|
141
|
+
|
142
|
+
xml do |wrapper|
|
143
|
+
send('org.jfrog.hudson.generic.ArtifactoryGenericConfigurator') do
|
144
|
+
details do
|
145
|
+
artifactoryUrl wrapper[:url]
|
146
|
+
artifactoryName wrapper[:'artifactory-name']
|
147
|
+
repositoryKey wrapper[:'release-repo']
|
148
|
+
snapshotsRepositoryKey wrapper.fetch(:'snapshot-repo', wrapper[:'release-repo'])
|
100
149
|
end
|
150
|
+
deployPattern wrapper[:publish]
|
151
|
+
resolvePattern
|
152
|
+
matrixParams wrapper[:properties]
|
153
|
+
deployBuildInfo wrapper[:'publish-build-info']
|
154
|
+
includeEnvVars false
|
155
|
+
envVarsPatterns do
|
156
|
+
includePatterns
|
157
|
+
excludePatterns '*password*,*secret*'
|
158
|
+
end
|
159
|
+
discardOldBuilds false
|
160
|
+
discardBuildArtifacts true
|
101
161
|
end
|
162
|
+
end
|
163
|
+
end
|
102
164
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
xml.disableLicenseAutoDiscovery false
|
128
|
-
xml.discardOldBuilds false
|
129
|
-
xml.discardBuildArtifacts true
|
130
|
-
xml.matrixParams
|
131
|
-
xml.enableIssueTrackerIntegration false
|
132
|
-
xml.aggregateBuildIssues false
|
133
|
-
xml.blackDuckRunChecks false
|
134
|
-
xml.blackDuckAppName
|
135
|
-
xml.blackDuckAppVersion
|
136
|
-
xml.blackDuckReportRecipients
|
137
|
-
xml.blackDuckScopes
|
138
|
-
xml.blackDuckIncludePublishedArtifacts false
|
139
|
-
xml.autoCreateMissingComponentRequests true
|
140
|
-
xml.autoDiscardStaleComponentRequests true
|
141
|
-
xml.filterExcludedArtifactsFromBuild false
|
165
|
+
wrapper do
|
166
|
+
name :maven3artifactory
|
167
|
+
plugin_id 123
|
168
|
+
min_version 0
|
169
|
+
announced false
|
170
|
+
|
171
|
+
xml do |wrapper|
|
172
|
+
send('org.jfrog.hudson.maven3.ArtifactoryMaven3Configurator') do # plugin='artifactory@2.2.1'
|
173
|
+
details do
|
174
|
+
artifactoryUrl wrapper[:url]
|
175
|
+
artifactoryName wrapper[:'artifactory-name']
|
176
|
+
repositoryKey wrapper[:'release-repo']
|
177
|
+
snapshotsRepositoryKey wrapper.fetch(:'snapshot-repo', wrapper[:'release-repo'])
|
178
|
+
end
|
179
|
+
deployArtifacts wrapper.fetch(:'deploy', true)
|
180
|
+
artifactDeploymentPatterns do
|
181
|
+
includePatterns
|
182
|
+
excludePatterns
|
183
|
+
end
|
184
|
+
includeEnvVars false
|
185
|
+
deployBuildInfo wrapper.fetch(:'publish-build-info', true)
|
186
|
+
envVarsPatterns do
|
187
|
+
includePatterns
|
188
|
+
excludePatterns '*password*,*secret*'
|
142
189
|
end
|
190
|
+
runChecks false
|
191
|
+
violationRecipients
|
192
|
+
includePublishArtifacts false
|
193
|
+
scopes
|
194
|
+
licenseAutoDiscovery true
|
195
|
+
disableLicenseAutoDiscovery false
|
196
|
+
discardOldBuilds false
|
197
|
+
discardBuildArtifacts true
|
198
|
+
matrixParams
|
199
|
+
enableIssueTrackerIntegration false
|
200
|
+
aggregateBuildIssues false
|
201
|
+
blackDuckRunChecks false
|
202
|
+
blackDuckAppName
|
203
|
+
blackDuckAppVersion
|
204
|
+
blackDuckReportRecipients
|
205
|
+
blackDuckScopes
|
206
|
+
blackDuckIncludePublishedArtifacts false
|
207
|
+
autoCreateMissingComponentRequests true
|
208
|
+
autoDiscardStaleComponentRequests true
|
209
|
+
filterExcludedArtifactsFromBuild false
|
143
210
|
end
|
144
211
|
end
|
145
212
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
require 'pp'
|
3
|
+
describe JenkinsPipelineBuilder::Compiler do
|
4
|
+
let(:compiler) { JenkinsPipelineBuilder::Compiler }
|
5
|
+
let(:settings_project) { { name: 'DummyPipeline', type: :project, value: { name: 'DummyPipeline', jobs: ['{{name}}-00', { '{{name}}-01' => { job_name: '{{name}}-02' } }] } } }
|
6
|
+
let(:settings_global) { { name: 'global', description: 'Do not edit this job through the web!', discard_days: '14', pipeline_repo: 'git@github.com:constantcontact/jenkins_pipeline_builder.git', pipeline_branch: 'master' } }
|
7
|
+
let(:settings_bag) { { name: 'DummyPipeline', description: 'Do not edit this job through the web!', discard_days: '14', pipeline_repo: 'git@github.com:constantcontact/jenkins_pipeline_builder.git', pipeline_branch: 'master' } }
|
8
|
+
let(:job0) { { name: '{{name}}-00', description: '{{description}}', scm_provider: 'git', scm_url: '{{pipeline_repo}}', scm_branch: '{{pipeline_branch}}', scm_params: { remote_name: 'origin', skip_tag: true }, wrappers: [{ ansicolor: true }], builders: [{ shell_command: "echo 'Running {{name}}'\necho 'About to run {{job@{{name}}-01}}'\n" }], publishers: [{ downstream: { project: '{{job@{{name}}-01}}' } }] } }
|
9
|
+
let(:job0_compiled) { { name: 'DummyPipeline-00', description: 'Do not edit this job through the web!', scm_provider: 'git', scm_url: 'git@github.com:constantcontact/jenkins_pipeline_builder.git', scm_branch: 'master', scm_params: { remote_name: 'origin', skip_tag: true }, wrappers: [{ ansicolor: true }], builders: [{ shell_command: "echo 'Running DummyPipeline'\necho 'About to run DummyPipeline-02'\n" }], publishers: [{ downstream: { project: 'DummyPipeline-02' } }] } }
|
10
|
+
let(:job2) { { name: '{{name}}-02', description: '{{description}}', scm_provider: 'git', scm_url: '{{pipeline_repo}}', scm_branch: '{{pipeline_branch}}', scm_params: { remote_name: 'origin', skip_tag: true }, wrappers: [{ ansicolor: true }], builders: [{ shell_command: "echo 'Running {{name}}'" }] } }
|
11
|
+
let(:job2_compiled) { { name: 'DummyPipeline-02', description: 'Do not edit this job through the web!', scm_provider: 'git', scm_url: 'git@github.com:constantcontact/jenkins_pipeline_builder.git', scm_branch: 'master', scm_params: { remote_name: 'origin', skip_tag: true }, wrappers: [{ ansicolor: true }], builders: [{ shell_command: "echo 'Running DummyPipeline'" }] } }
|
12
|
+
let(:job_collection) { { '{{name}}-00' => { name: '{{name}}-00', type: :job, value: { name: '{{name}}-00', description: '{{description}}', scm_provider: 'git', scm_url: '{{pipeline_repo}}', scm_branch: '{{pipeline_branch}}', scm_params: { remote_name: 'origin', skip_tag: true }, wrappers: [{ ansicolor: true }], builders: [{ shell_command: "echo 'Running {{name}}'\necho 'About to run {{job@{{name}}-01}}'\n" }], publishers: [{ downstream: { project: '{{job@{{name}}-01}}' } }] } }, '{{name}}-01' => { name: '{{name}}-01', type: :job, value: { name: '{{name}}-02', description: '{{description}}', scm_provider: 'git', scm_url: '{{pipeline_repo}}', scm_branch: '{{pipeline_branch}}', scm_params: { remote_name: 'origin', skip_tag: true }, wrappers: [{ ansicolor: true }], builders: [{ shell_command: "echo 'Running {{name}}'" }] }, job_name: '{{name}}-02' }, 'global' => { name: 'global', type: :defaults, value: { name: 'global', description: 'Do not edit this job through the web!', discard_days: '14', pipeline_repo: 'git@github.com:constantcontact/jenkins_pipeline_builder.git', pipeline_branch: 'master' } }, 'DummyPipeline' => { name: 'DummyPipeline', type: :project, value: { name: 'DummyPipeline', jobs: [{ '{{name}}-00' => {}, result: { name: 'DummyPipeline-00', description: 'Do not edit this job through the web!', scm_provider: 'git', scm_url: 'git@github.com:constantcontact/jenkins_pipeline_builder.git', scm_branch: 'master', scm_params: { remote_name: 'origin', skip_tag: true }, wrappers: [{ ansicolor: true }], builders: [{ shell_command: "echo 'Running DummyPipeline'\necho 'About to run DummyPipeline-02'\n" }], publishers: [{ downstream: { project: 'DummyPipeline-02' } }] } }, { '{{name}}-01' => { job_name: '{{name}}-02' } }] }, settings: { name: 'DummyPipeline', description: 'Do not edit this job through the web!', discard_days: '14', pipeline_repo: 'git@github.com:constantcontact/jenkins_pipeline_builder.git', pipeline_branch: 'master' } } } }
|
13
|
+
|
14
|
+
describe '#get_settings_bag' do
|
15
|
+
it 'merge settings' do
|
16
|
+
settings = compiler.get_settings_bag(settings_project, settings_global)
|
17
|
+
expect(settings).to eq(settings_bag)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#compile' do
|
22
|
+
it 'compile a job with a name change' do
|
23
|
+
result = compiler.compile(job2, settings_bag, job_collection)
|
24
|
+
expect(result[1]).to eq(job2_compiled)
|
25
|
+
end
|
26
|
+
it 'compile a job with a downstream name change' do
|
27
|
+
result = compiler.compile(job0, settings_bag, job_collection)
|
28
|
+
expect(result[1]).to eq(job0_compiled)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe JenkinsPipelineBuilder::Extension do
|
4
|
+
subject(:extension) { JenkinsPipelineBuilder::Extension.new }
|
5
|
+
context 'defaults' do
|
6
|
+
it 'min_version is nil' do
|
7
|
+
expect(extension.min_version).to be nil
|
8
|
+
end
|
9
|
+
it 'name is nil' do
|
10
|
+
expect(extension.name).to be nil
|
11
|
+
end
|
12
|
+
it 'plugin_id is nil' do
|
13
|
+
expect(extension.plugin_id).to be nil
|
14
|
+
end
|
15
|
+
it 'type is nil' do
|
16
|
+
expect(extension.type).to be nil
|
17
|
+
end
|
18
|
+
it 'path is nil' do
|
19
|
+
expect(extension.path).to be nil
|
20
|
+
end
|
21
|
+
it 'announced is true' do
|
22
|
+
expect(extension.announced).to be true
|
23
|
+
end
|
24
|
+
it 'jenkins_name has the correct default' do
|
25
|
+
expect(extension.jenkins_name).to eq 'No jenkins display name set'
|
26
|
+
end
|
27
|
+
it 'description has the correct default' do
|
28
|
+
expect(extension.description).to eq 'No description set'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'methods' do
|
33
|
+
context 'name' do
|
34
|
+
it 'sets the name if a parameter is provided' do
|
35
|
+
extension.name('foo')
|
36
|
+
expect(extension.name).to eq 'foo'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
context 'plugin_id' do
|
40
|
+
it 'sets the plugin_id if a parameter is provided' do
|
41
|
+
extension.plugin_id('foo')
|
42
|
+
expect(extension.plugin_id).to eq 'foo'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
context 'min_version' do
|
46
|
+
it 'sets the min_version if a parameter is provided' do
|
47
|
+
extension.min_version('foo')
|
48
|
+
expect(extension.min_version).to eq 'foo'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
context 'jenkins_name' do
|
52
|
+
it 'sets the jenkins_name if a parameter is provided' do
|
53
|
+
extension.jenkins_name('foo')
|
54
|
+
expect(extension.jenkins_name).to eq 'foo'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
context 'description' do
|
58
|
+
it 'sets the description if a parameter is provided' do
|
59
|
+
extension.description('foo')
|
60
|
+
expect(extension.description).to eq 'foo'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
context 'path' do
|
64
|
+
it 'sets the path if a parameter is provided' do
|
65
|
+
extension.path('foo')
|
66
|
+
expect(extension.path).to eq 'foo'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
context 'announced' do
|
70
|
+
it 'sets the announced if a parameter is provided' do
|
71
|
+
extension.announced('foo')
|
72
|
+
expect(extension.announced).to eq 'foo'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
context 'type' do
|
76
|
+
it 'sets the type if a parameter is provided' do
|
77
|
+
extension.type('foo')
|
78
|
+
expect(extension.type).to eq 'foo'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
context 'xml' do
|
82
|
+
it 'saves the block' do
|
83
|
+
extension.xml do
|
84
|
+
true
|
85
|
+
end
|
86
|
+
expect(extension.xml.call).to be true
|
87
|
+
end
|
88
|
+
it 'uses the path if provided' do
|
89
|
+
extension.xml('foo') do
|
90
|
+
true
|
91
|
+
end
|
92
|
+
expect(extension.path).to eq 'foo'
|
93
|
+
end
|
94
|
+
it 'returns the saved block if there none is provided' do
|
95
|
+
extension.xml do
|
96
|
+
true
|
97
|
+
end
|
98
|
+
expect(extension.xml).to be_kind_of Proc
|
99
|
+
end
|
100
|
+
end
|
101
|
+
context 'after' do
|
102
|
+
it 'saves the block' do
|
103
|
+
extension.after do
|
104
|
+
true
|
105
|
+
end
|
106
|
+
expect(extension.after.call).to be true
|
107
|
+
end
|
108
|
+
it 'returns the saved block if there none is provided' do
|
109
|
+
extension.after do
|
110
|
+
true
|
111
|
+
end
|
112
|
+
expect(extension.after).to be_kind_of Proc
|
113
|
+
end
|
114
|
+
end
|
115
|
+
context 'before' do
|
116
|
+
it 'saves the block' do
|
117
|
+
extension.before do
|
118
|
+
true
|
119
|
+
end
|
120
|
+
expect(extension.before.call).to be true
|
121
|
+
end
|
122
|
+
it 'returns the saved block if there none is provided' do
|
123
|
+
extension.before do
|
124
|
+
true
|
125
|
+
end
|
126
|
+
expect(extension.before).to be_kind_of Proc
|
127
|
+
end
|
128
|
+
end
|
129
|
+
context 'valid?' do
|
130
|
+
it 'returns true if errors is empty' do
|
131
|
+
extension.name 'foo'
|
132
|
+
extension.plugin_id 'foo'
|
133
|
+
extension.min_version 'foo'
|
134
|
+
extension.type 'foo'
|
135
|
+
extension.path 'foo'
|
136
|
+
expect(extension.errors).to be_empty
|
137
|
+
expect(extension.valid?).to be true
|
138
|
+
end
|
139
|
+
it 'returns false if errors is not empty' do
|
140
|
+
expect(extension.errors).to_not be_empty
|
141
|
+
expect(extension.valid?).to be false
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|