jenkins_pipeline_builder 0.5.0 → 0.5.1
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 +2 -1
- data/README.md +22 -0
- data/lib/jenkins_pipeline_builder/builders.rb +50 -0
- data/lib/jenkins_pipeline_builder/generator.rb +4 -2
- data/lib/jenkins_pipeline_builder/job_builder.rb +2 -0
- data/lib/jenkins_pipeline_builder/publishers.rb +9 -0
- data/lib/jenkins_pipeline_builder/version.rb +1 -1
- data/spec/unit_tests/fixtures/files/archive_artifact.xml +23 -0
- data/spec/unit_tests/fixtures/files/archive_artifact.yaml +5 -0
- data/spec/unit_tests/fixtures/files/copy_artifact.xml +30 -0
- data/spec/unit_tests/fixtures/files/copy_artifact.yaml +14 -0
- data/spec/unit_tests/fixtures/files/git_include_exclude.xml +53 -0
- data/spec/unit_tests/fixtures/files/git_include_exclude.yaml +8 -0
- data/spec/unit_tests/generator_spec.rb +3 -0
- metadata +13 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07be75a38a219e527c74b522aba4798a01b41433
|
4
|
+
data.tar.gz: 296de68ba768f231001b279641c4baa28d971e30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d38d2dce1fb6bc2060f1de5d798cbaad0b87afdfd851ebf0367a39fca69d6cfc0e7f01f6b6d4e2f64a2aa5f477ef843677af2dcc94f86630862c9f24db92af8f
|
7
|
+
data.tar.gz: b957a87d0ea5fe5ec70f3470114362a0802896d224906b5a37bb959c6d58eafe1e53a1cc82082fad38994c181778c4d09fb2a7e9697f90e1e9679d16a2f3ab45
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -36,11 +36,12 @@ Style/ClassAndModuleChildren:
|
|
36
36
|
# Offense count: 6
|
37
37
|
# Configuration parameters: CountComments.
|
38
38
|
Style/ClassLength:
|
39
|
+
Enabled: false
|
39
40
|
Max: 506
|
40
41
|
|
41
42
|
# Offense count: 12
|
42
43
|
Style/CyclomaticComplexity:
|
43
|
-
Max:
|
44
|
+
Max: 20
|
44
45
|
|
45
46
|
# Offense count: 17
|
46
47
|
Style/Documentation:
|
data/README.md
CHANGED
@@ -115,6 +115,8 @@ Here's a high level overview of what's available:
|
|
115
115
|
recursive_update: true
|
116
116
|
wipe_workspace: true
|
117
117
|
skip_tag: true # Optional, defaults to false
|
118
|
+
excluded_regions: region
|
119
|
+
included_regions: region
|
118
120
|
shell_command: '. commit_build.sh'
|
119
121
|
hipchat:
|
120
122
|
room: room name here
|
@@ -173,6 +175,21 @@ Here's a high level overview of what's available:
|
|
173
175
|
fail: FAILURE # Fail this build step if the triggered build is worse or equal to
|
174
176
|
mark_fail: SUCCESS # Mark this build as failure if the triggered build is worse or equal to
|
175
177
|
mark_unstable: UNSTABLE # Mark this build as unstable if the triggered build is worse or equal to
|
178
|
+
- copy_artifact:
|
179
|
+
project: nameStr # Name of the project
|
180
|
+
artifacts: 'artifact.txt' # Selector for artifacts
|
181
|
+
target_directory: 'artifacts' # Where the artifacts should go, blank for Workspace root
|
182
|
+
filter: 'test=true' # String of filters, PARAM1=VALUE1,PARAM2=VALUE2, Optional
|
183
|
+
fingerprint: true # Optional, true or false, defaults to true
|
184
|
+
flatten: false # Optional, true or false, defaults to false
|
185
|
+
optional: false # Optional, true or false, defaults to false
|
186
|
+
selector: # Optional
|
187
|
+
type: status # Defaults to status, options: status, saved, triggered, permalink, specific, workspace, parameter
|
188
|
+
stable: true # Use if type = 'status', true or false
|
189
|
+
fallback: true # Use if type = 'triggered', true or false
|
190
|
+
id: lastBuild # Use if type = 'permalink', options: lastBuild, lastStableBuild, lastSuccessfulBuild, lastFailedBuild, lastUnstableBuild, lastUnsucceessfulBuild
|
191
|
+
number: '123' # Use if type = 'specific', the number of the build to use
|
192
|
+
param: 'BUILD_SELECTOR' # Use if type = 'parameter', the build parameter name
|
176
193
|
wrappers:
|
177
194
|
- timestamp: true
|
178
195
|
- ansicolor: true
|
@@ -229,6 +246,11 @@ Here's a high level overview of what's available:
|
|
229
246
|
PARAM1=value1
|
230
247
|
PARAM2=value2
|
231
248
|
- file: promote-job-params
|
249
|
+
- archive_artifact:
|
250
|
+
artifacts: 'artifact.txt' #Artifact include string/pattern
|
251
|
+
exclude: '' # Optional, exclude string/pattern
|
252
|
+
latest_only: false # Optional, true or false, defaults to false
|
253
|
+
allow_empty: false # Optional, true or false, defaults to false
|
232
254
|
triggers:
|
233
255
|
- git_push: true
|
234
256
|
- scm_polling: 'H/5 * * * *'
|
@@ -170,5 +170,55 @@ module JenkinsPipelineBuilder
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
173
|
+
|
174
|
+
def self.build_copy_artifact(params, xml)
|
175
|
+
xml.send('hudson.plugins.copyartifact.CopyArtifact', 'plugin' => 'copyartifact') do
|
176
|
+
xml.project params[:project]
|
177
|
+
xml.filter params[:artifacts]
|
178
|
+
xml.target params[:target_directory]
|
179
|
+
xml.parameters params[:filter] if params[:filter]
|
180
|
+
if params[:selector] && params[:selector][:type]
|
181
|
+
case params[:selector][:type]
|
182
|
+
when 'saved'
|
183
|
+
xml.send('selector', 'class' => 'hudson.plugins.copyartifact.SavedBuildSelector')
|
184
|
+
when 'triggered'
|
185
|
+
xml.send('selector', 'class' => 'hudson.plugins.copyartifact.TriggeredBuildSelector') do
|
186
|
+
xml.fallbackToLastSuccessful params[:selector][:fallback] if params[:selector][:fallback]
|
187
|
+
end
|
188
|
+
when 'permalink'
|
189
|
+
xml.send('selector', 'class' => 'hudson.plugins.copyartifact.PermalinkBuildSelector') do
|
190
|
+
xml.id params[:selector][:id] if params[:selector][:id]
|
191
|
+
end
|
192
|
+
when 'specific'
|
193
|
+
xml.send('selector', 'class' => 'hudson.plugins.copyartifact.SpecificBuildSelector') do
|
194
|
+
xml.buildNumber params[:selector][:number] if params[:selector][:number]
|
195
|
+
end
|
196
|
+
when 'workspace'
|
197
|
+
xml.send('selector', 'class' => 'hudson.plugins.copyartifact.WorkspaceSelector')
|
198
|
+
when 'parameter'
|
199
|
+
xml.send('selector', 'class' => 'hudson.plugins.copyartifact.ParameterizedBuildSelector') do
|
200
|
+
xml.parameterName params[:selector][:param] if params[:selector][:param]
|
201
|
+
end
|
202
|
+
else
|
203
|
+
xml.send('selector', 'class' => 'hudson.plugins.copyartifact.StatusBuildSelector') do
|
204
|
+
xml.stable params[:selector][:stable] if params[:selector][:stable]
|
205
|
+
end
|
206
|
+
end
|
207
|
+
else
|
208
|
+
xml.send('selector', 'class' => 'hudson.plugins.copyartifact.StatusBuildSelector')
|
209
|
+
end
|
210
|
+
if params[:fingerprint].nil?
|
211
|
+
xml.doNotFingerprintArtifacts false
|
212
|
+
else
|
213
|
+
if params[:fingerprint].to_s == 'true'
|
214
|
+
xml.doNotFingerprintArtifacts false
|
215
|
+
else
|
216
|
+
xml.doNotFingerprintArtifacts true
|
217
|
+
end
|
218
|
+
end
|
219
|
+
xml.flatten true if params[:flatten]
|
220
|
+
xml.optional true if params[:optional]
|
221
|
+
end
|
222
|
+
end
|
173
223
|
end
|
174
224
|
end
|
@@ -62,7 +62,8 @@ module JenkinsPipelineBuilder
|
|
62
62
|
shell_command: Builders.method(:build_shell_command),
|
63
63
|
maven3: Builders.method(:build_maven3),
|
64
64
|
blocking_downstream: Builders.method(:blocking_downstream),
|
65
|
-
remote_job: Builders.method(:start_remote_job)
|
65
|
+
remote_job: Builders.method(:start_remote_job),
|
66
|
+
copy_artifact: Builders.method(:build_copy_artifact)
|
66
67
|
},
|
67
68
|
method:
|
68
69
|
->(registry, params, n_xml) { @module_registry.run_registry_on_path('//builders', registry, params, n_xml) }
|
@@ -76,7 +77,8 @@ module JenkinsPipelineBuilder
|
|
76
77
|
junit_result: Publishers.method(:publish_junit),
|
77
78
|
coverage_result: Publishers.method(:publish_rcov),
|
78
79
|
post_build_script: Publishers.method(:post_build_script),
|
79
|
-
groovy_postbuild: Publishers.method(:groovy_postbuild)
|
80
|
+
groovy_postbuild: Publishers.method(:groovy_postbuild),
|
81
|
+
archive_artifact: Publishers.method(:archive_artifact)
|
80
82
|
},
|
81
83
|
method:
|
82
84
|
->(registry, params, n_xml) { @module_registry.run_registry_on_path('//publishers', registry, params, n_xml) }
|
@@ -35,6 +35,8 @@ module JenkinsPipelineBuilder
|
|
35
35
|
XmlHelper.update_node_text(n_xml, '//scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/name', params[:remote_name]) if params[:remote_name]
|
36
36
|
XmlHelper.update_node_text(n_xml, '//scm/skipTag', params[:skip_tag]) if params[:skip_tag]
|
37
37
|
XmlHelper.update_node_text(n_xml, '//scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/refspec', params[:refspec]) if params[:refspec]
|
38
|
+
XmlHelper.update_node_text(n_xml, '//scm/excludedRegions', params[:excluded_regions]) if params[:excluded_regions]
|
39
|
+
XmlHelper.update_node_text(n_xml, '//scm/includedRegions', params[:included_regions]) if params[:included_regions]
|
38
40
|
end
|
39
41
|
|
40
42
|
def self.hipchat_notifier(params, n_xml)
|
@@ -139,5 +139,14 @@ module JenkinsPipelineBuilder
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
142
|
+
|
143
|
+
def self.archive_artifact(params, xml)
|
144
|
+
xml.send('hudson.tasks.ArtifactArchiver') do
|
145
|
+
xml.artifacts params[:artifacts]
|
146
|
+
xml.excludes params[:excludes] if params[:excludes]
|
147
|
+
xml.latestOnly params[:latest_only] || false
|
148
|
+
xml.allowEmptyArchive params[:allow_empty] || false
|
149
|
+
end
|
150
|
+
end
|
142
151
|
end
|
143
152
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project>
|
3
|
+
<actions/>
|
4
|
+
<description/>
|
5
|
+
<keepDependencies>false</keepDependencies>
|
6
|
+
<properties/>
|
7
|
+
<scm class="hudson.scm.NullSCM"/>
|
8
|
+
<canRoam>true</canRoam>
|
9
|
+
<disabled>false</disabled>
|
10
|
+
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
11
|
+
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
12
|
+
<triggers class="vector"/>
|
13
|
+
<concurrentBuild>false</concurrentBuild>
|
14
|
+
<builders/>
|
15
|
+
<publishers>
|
16
|
+
<hudson.tasks.ArtifactArchiver>
|
17
|
+
<artifacts>artifact.txt</artifacts>
|
18
|
+
<latestOnly>false</latestOnly>
|
19
|
+
<allowEmptyArchive>false</allowEmptyArchive>
|
20
|
+
</hudson.tasks.ArtifactArchiver>
|
21
|
+
</publishers>
|
22
|
+
<buildWrappers/>
|
23
|
+
</project>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project>
|
3
|
+
<actions/>
|
4
|
+
<description/>
|
5
|
+
<keepDependencies>false</keepDependencies>
|
6
|
+
<properties/>
|
7
|
+
<scm class="hudson.scm.NullSCM"/>
|
8
|
+
<canRoam>true</canRoam>
|
9
|
+
<disabled>false</disabled>
|
10
|
+
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
11
|
+
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
12
|
+
<triggers class="vector"/>
|
13
|
+
<concurrentBuild>false</concurrentBuild>
|
14
|
+
<builders>
|
15
|
+
<hudson.plugins.copyartifact.CopyArtifact plugin="copyartifact">
|
16
|
+
<project>test</project>
|
17
|
+
<filter>artifact.txt</filter>
|
18
|
+
<target>artifacts</target>
|
19
|
+
<parameters>test=true</parameters>
|
20
|
+
<selector class="hudson.plugins.copyartifact.TriggeredBuildSelector">
|
21
|
+
<fallbackToLastSuccessful>true</fallbackToLastSuccessful>
|
22
|
+
</selector>
|
23
|
+
<doNotFingerprintArtifacts>false</doNotFingerprintArtifacts>
|
24
|
+
<flatten>true</flatten>
|
25
|
+
<optional>true</optional>
|
26
|
+
</hudson.plugins.copyartifact.CopyArtifact>
|
27
|
+
</builders>
|
28
|
+
<publishers/>
|
29
|
+
<buildWrappers/>
|
30
|
+
</project>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
- job:
|
2
|
+
name: copy_artifact
|
3
|
+
builders:
|
4
|
+
- copy_artifact:
|
5
|
+
project: 'test'
|
6
|
+
artifacts: 'artifact.txt'
|
7
|
+
target_directory: 'artifacts'
|
8
|
+
filter: 'test=true'
|
9
|
+
fingerprint: true
|
10
|
+
flatten: true
|
11
|
+
optional: true
|
12
|
+
selector:
|
13
|
+
type: triggered
|
14
|
+
fallback: true
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project>
|
3
|
+
<actions/>
|
4
|
+
<description/>
|
5
|
+
<keepDependencies>false</keepDependencies>
|
6
|
+
<properties/>
|
7
|
+
<scm class="hudson.plugins.git.GitSCM">
|
8
|
+
<configVersion>2</configVersion>
|
9
|
+
<userRemoteConfigs>
|
10
|
+
<hudson.plugins.git.UserRemoteConfig>
|
11
|
+
<name/>
|
12
|
+
<refspec/>
|
13
|
+
<url>git@github.com:devops/repo.git</url>
|
14
|
+
</hudson.plugins.git.UserRemoteConfig>
|
15
|
+
</userRemoteConfigs>
|
16
|
+
<branches>
|
17
|
+
<hudson.plugins.git.BranchSpec>
|
18
|
+
<name>master</name>
|
19
|
+
</hudson.plugins.git.BranchSpec>
|
20
|
+
</branches>
|
21
|
+
<disableSubmodules>false</disableSubmodules>
|
22
|
+
<recursiveSubmodules>false</recursiveSubmodules>
|
23
|
+
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
24
|
+
<authorOrCommitter>false</authorOrCommitter>
|
25
|
+
<clean>false</clean>
|
26
|
+
<wipeOutWorkspace>false</wipeOutWorkspace>
|
27
|
+
<pruneBranches>false</pruneBranches>
|
28
|
+
<remotePoll>false</remotePoll>
|
29
|
+
<ignoreNotifyCommit>false</ignoreNotifyCommit>
|
30
|
+
<useShallowClone>false</useShallowClone>
|
31
|
+
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
|
32
|
+
<gitTool>Default</gitTool>
|
33
|
+
<submoduleCfg class="list"/>
|
34
|
+
<relativeTargetDir/>
|
35
|
+
<reference/>
|
36
|
+
<excludedRegions>test1</excludedRegions>
|
37
|
+
<excludedUsers/>
|
38
|
+
<gitConfigName/>
|
39
|
+
<gitConfigEmail/>
|
40
|
+
<skipTag>false</skipTag>
|
41
|
+
<includedRegions>test2</includedRegions>
|
42
|
+
<scmName/>
|
43
|
+
</scm>
|
44
|
+
<canRoam>true</canRoam>
|
45
|
+
<disabled>false</disabled>
|
46
|
+
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
47
|
+
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
48
|
+
<triggers class="vector"/>
|
49
|
+
<concurrentBuild>false</concurrentBuild>
|
50
|
+
<builders/>
|
51
|
+
<publishers/>
|
52
|
+
<buildWrappers/>
|
53
|
+
</project>
|
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.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Moochnick
|
@@ -365,16 +365,22 @@ files:
|
|
365
365
|
- spec/unit_tests/fixtures/files/Job-Generate-From-Template.yaml
|
366
366
|
- spec/unit_tests/fixtures/files/Job-Multi-Project.xml
|
367
367
|
- spec/unit_tests/fixtures/files/Job-Multi-Project.yaml
|
368
|
+
- spec/unit_tests/fixtures/files/archive_artifact.xml
|
369
|
+
- spec/unit_tests/fixtures/files/archive_artifact.yaml
|
368
370
|
- spec/unit_tests/fixtures/files/choice_parameter.xml
|
369
371
|
- spec/unit_tests/fixtures/files/choice_parameter.yaml
|
370
372
|
- spec/unit_tests/fixtures/files/concurrent_build.xml
|
371
373
|
- spec/unit_tests/fixtures/files/concurrent_build.yaml
|
374
|
+
- spec/unit_tests/fixtures/files/copy_artifact.xml
|
375
|
+
- spec/unit_tests/fixtures/files/copy_artifact.yaml
|
372
376
|
- spec/unit_tests/fixtures/files/discard_old.xml
|
373
377
|
- spec/unit_tests/fixtures/files/discard_old.yaml
|
374
378
|
- spec/unit_tests/fixtures/files/downstream.xml
|
375
379
|
- spec/unit_tests/fixtures/files/downstream.yaml
|
376
380
|
- spec/unit_tests/fixtures/files/downstream_blocking.xml
|
377
381
|
- spec/unit_tests/fixtures/files/downstream_blocking.yaml
|
382
|
+
- spec/unit_tests/fixtures/files/git_include_exclude.xml
|
383
|
+
- spec/unit_tests/fixtures/files/git_include_exclude.yaml
|
378
384
|
- spec/unit_tests/fixtures/files/groovy_postbuild.xml
|
379
385
|
- spec/unit_tests/fixtures/files/groovy_postbuild.yaml
|
380
386
|
- spec/unit_tests/fixtures/files/periodic_build.xml
|
@@ -443,16 +449,22 @@ test_files:
|
|
443
449
|
- spec/unit_tests/fixtures/files/Job-Generate-From-Template.yaml
|
444
450
|
- spec/unit_tests/fixtures/files/Job-Multi-Project.xml
|
445
451
|
- spec/unit_tests/fixtures/files/Job-Multi-Project.yaml
|
452
|
+
- spec/unit_tests/fixtures/files/archive_artifact.xml
|
453
|
+
- spec/unit_tests/fixtures/files/archive_artifact.yaml
|
446
454
|
- spec/unit_tests/fixtures/files/choice_parameter.xml
|
447
455
|
- spec/unit_tests/fixtures/files/choice_parameter.yaml
|
448
456
|
- spec/unit_tests/fixtures/files/concurrent_build.xml
|
449
457
|
- spec/unit_tests/fixtures/files/concurrent_build.yaml
|
458
|
+
- spec/unit_tests/fixtures/files/copy_artifact.xml
|
459
|
+
- spec/unit_tests/fixtures/files/copy_artifact.yaml
|
450
460
|
- spec/unit_tests/fixtures/files/discard_old.xml
|
451
461
|
- spec/unit_tests/fixtures/files/discard_old.yaml
|
452
462
|
- spec/unit_tests/fixtures/files/downstream.xml
|
453
463
|
- spec/unit_tests/fixtures/files/downstream.yaml
|
454
464
|
- spec/unit_tests/fixtures/files/downstream_blocking.xml
|
455
465
|
- spec/unit_tests/fixtures/files/downstream_blocking.yaml
|
466
|
+
- spec/unit_tests/fixtures/files/git_include_exclude.xml
|
467
|
+
- spec/unit_tests/fixtures/files/git_include_exclude.yaml
|
456
468
|
- spec/unit_tests/fixtures/files/groovy_postbuild.xml
|
457
469
|
- spec/unit_tests/fixtures/files/groovy_postbuild.yaml
|
458
470
|
- spec/unit_tests/fixtures/files/periodic_build.xml
|