jenkins_pipeline_builder 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/jenkins_pipeline_builder/extensions/job_attributes.rb +47 -0
- data/lib/jenkins_pipeline_builder/extensions/publishers.rb +9 -0
- data/lib/jenkins_pipeline_builder/version.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/extensions/job_attributes_spec.rb +89 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27bfce0d8e1ed49ce1f7d1712159c7085aab313e
|
4
|
+
data.tar.gz: d441dec1b686f09b8fc0a31f8f29c429ff2c33b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73cf874e69635ebcb6e463d190bca2672c9f05dfbde153167abb70e4e333d55cc4aa122ae7c3518e36998d444162c548d41231440a85d4cf35609958d77224da
|
7
|
+
data.tar.gz: 572698d42843aa3a019ac5a3642f87282450e3c9bc0d69d146b17de3d21a9e2aca784b096b1073d38f255f75ea876bd9f2c2da1771f7e8473d454f29123f1863
|
data/README.md
CHANGED
@@ -87,7 +87,7 @@ Here's a high level overview of what's available:
|
|
87
87
|
```yaml
|
88
88
|
- job:
|
89
89
|
name: nameStr # Name of your Job
|
90
|
-
job_type: free_style # Optional [free_style|multi_project]
|
90
|
+
job_type: free_style # Optional [free_style|multi_project|job_dsl|build_flow|pull_request_generator]
|
91
91
|
concurrent_build: true or false
|
92
92
|
discard_old: # Discard old builds after:
|
93
93
|
days: 1 # Optional, number of days after which the build is deleted
|
@@ -78,7 +78,14 @@ job_attribute do
|
|
78
78
|
xpath('//scm/skipTag').remove if params[:skip_tag]
|
79
79
|
xpath('//scm/excludedRegions').remove if params[:excluded_regions]
|
80
80
|
xpath('//scm/includedRegions').remove if params[:included_regions]
|
81
|
+
end
|
81
82
|
|
83
|
+
before version: '2.0' do |params|
|
84
|
+
if params[:remote_name] || params[:refspec]
|
85
|
+
remote_url = xpath('//scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/url').first
|
86
|
+
params[:remote_url] = remote_url.content if remote_url
|
87
|
+
xpath('//scm/userRemoteConfigs').remove
|
88
|
+
end
|
82
89
|
end
|
83
90
|
|
84
91
|
xml path: '//scm' do |params|
|
@@ -99,6 +106,46 @@ job_attribute do
|
|
99
106
|
excludedRegions params[:excluded_regions] if params[:excluded_regions]
|
100
107
|
includedRegions params[:included_regions] if params[:included_regions]
|
101
108
|
end
|
109
|
+
|
110
|
+
xml version: '2.0', path: '//scm' do |params|
|
111
|
+
configVersion 2
|
112
|
+
userRemoteConfigs do
|
113
|
+
send('hudson.plugins.git.UserRemoteConfig') do
|
114
|
+
name params[:remote_name] if params[:remote_name]
|
115
|
+
refspec params[:refspec] if params[:refspec]
|
116
|
+
url params[:remote_url] if params[:remote_url]
|
117
|
+
credentialsId params[:credentials_id] if params[:credentials_id]
|
118
|
+
end
|
119
|
+
end
|
120
|
+
doGenerateSubmoduleConfigurations false
|
121
|
+
submoduleCfg
|
122
|
+
extensions do
|
123
|
+
send('hudson.plugins.git.extensions.impl.WipeWorkspace') if params[:wipe_workspace]
|
124
|
+
if params[:local_branch]
|
125
|
+
send('hudson.plugins.git.extensions.impl.LocalWorkspace') do
|
126
|
+
localBranch params[:local_branch]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
if params[:recursive_update]
|
130
|
+
send('hudson.plugins.git.extensions.impl.SubmoduleOption') do
|
131
|
+
disableSubmodules false
|
132
|
+
recursiveSubmodules true
|
133
|
+
trackingSubmodules false
|
134
|
+
end
|
135
|
+
end
|
136
|
+
if params[:excluded_users]
|
137
|
+
send('hudson.plugins.git.extensions.impl.UserExclusion') do
|
138
|
+
excludedUser params[:excluded_users]
|
139
|
+
end
|
140
|
+
end
|
141
|
+
if params[:included_regions] || params[:excluded_regions]
|
142
|
+
send('hudson.plugins.git.extensions.impl.PathRestrictions') do
|
143
|
+
includedRegions params[:included_regions] if params[:included_regions]
|
144
|
+
excludedRegions params[:excluded_regions] if params[:excluded_regions]
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
102
149
|
end
|
103
150
|
|
104
151
|
job_attribute do
|
@@ -102,6 +102,15 @@ publisher do
|
|
102
102
|
configVersion params[:configVersion] || 2
|
103
103
|
pushMerge params[:'push-merge'] || false
|
104
104
|
pushOnlyIfSuccess params[:'push-only-if-success'] || false
|
105
|
+
if params[:tag_name]
|
106
|
+
tagsToPush do
|
107
|
+
send 'hudson.plugins.git.GitPublisher_-TagToPush' do
|
108
|
+
targetRepoName params[:target_repo]
|
109
|
+
tagName params[:tag_name]
|
110
|
+
createTag params[:create_tag] || false
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
105
114
|
branchesToPush do
|
106
115
|
send('hudson.plugins.git.GitPublisher_-BranchToPush') do
|
107
116
|
targetRepoName params[:targetRepoName] || 'origin'
|
@@ -40,8 +40,6 @@ describe 'job_attributes' do
|
|
40
40
|
|
41
41
|
context 'scm params' do
|
42
42
|
before :each do
|
43
|
-
allow(JenkinsPipelineBuilder.client).to receive(:plugin).and_return double(
|
44
|
-
list_installed: { 'git' => '20.0' })
|
45
43
|
|
46
44
|
builder = Nokogiri::XML::Builder.new { |xml| xml.scm }
|
47
45
|
@n_xml = builder.doc
|
@@ -54,37 +52,108 @@ describe 'job_attributes' do
|
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
55
|
+
context '>= 2.0' do
|
56
|
+
before :each do
|
57
|
+
JenkinsPipelineBuilder.registry.registry[:job][:scm_params].installed_version = '2.0'
|
58
|
+
end
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
+
it 'sets the config version' do
|
61
|
+
params = { scm_params: { refspec: :bar, remote_name: :foo }, scm_url: 'http://foo.com' }
|
60
62
|
|
61
|
-
|
63
|
+
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
|
64
|
+
|
65
|
+
scm_config = @n_xml.xpath('//scm').first
|
66
|
+
|
67
|
+
expect(scm_config.css('configVersion').first).to be_truthy
|
68
|
+
expect(scm_config.css('configVersion').first.content).to eq '2'
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'writes a single block if refspec and remote_name are specified' do
|
72
|
+
params = { scm_params: { refspec: :bar, remote_name: :foo }, scm_url: 'http://foo.com' }
|
62
73
|
|
63
|
-
|
74
|
+
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
|
64
75
|
|
65
|
-
|
76
|
+
remote_config = @n_xml.xpath('//scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig').first
|
66
77
|
|
67
|
-
|
68
|
-
expect(remote_config.css('refspec').first).to be_truthy
|
78
|
+
expect(remote_config.name).to match 'hudson.plugins.git.UserRemoteConfig'
|
69
79
|
|
70
|
-
|
71
|
-
|
80
|
+
expect(remote_config.css('name').first).to be_truthy
|
81
|
+
expect(remote_config.css('refspec').first).to be_truthy
|
82
|
+
|
83
|
+
expect(remote_config.css('name').first.content).to eq 'foo'
|
84
|
+
expect(remote_config.css('refspec').first.content).to eq 'bar'
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'sets all the options' do
|
88
|
+
params = {
|
89
|
+
scm_params: {
|
90
|
+
local_branch: :local,
|
91
|
+
recursive_update: true,
|
92
|
+
excluded_users: :exclude_me,
|
93
|
+
included_regions: :included_region,
|
94
|
+
excluded_regions: :excluded_region
|
95
|
+
},
|
96
|
+
scm_url: 'http://foo.com'
|
97
|
+
}
|
98
|
+
|
99
|
+
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
|
100
|
+
|
101
|
+
scm_config = @n_xml.xpath('//scm').first
|
102
|
+
|
103
|
+
expect(scm_config.css('disableSubmodules').first).to be_truthy
|
104
|
+
expect(scm_config.css('recursiveSubmodules').first).to be_truthy
|
105
|
+
expect(scm_config.css('trackingSubmodules').first).to be_truthy
|
106
|
+
expect(scm_config.css('localBranch').first).to be_truthy
|
107
|
+
expect(scm_config.css('excludedUser').first).to be_truthy
|
108
|
+
expect(scm_config.css('includedRegions').first).to be_truthy
|
109
|
+
expect(scm_config.css('excludedRegions').first).to be_truthy
|
110
|
+
|
111
|
+
expect(scm_config.css('disableSubmodules').first.content).to eq 'false'
|
112
|
+
expect(scm_config.css('recursiveSubmodules').first.content).to eq 'true'
|
113
|
+
expect(scm_config.css('trackingSubmodules').first.content).to eq 'false'
|
114
|
+
expect(scm_config.css('localBranch').first.content).to eq 'local'
|
115
|
+
expect(scm_config.css('excludedUser').first.content).to eq 'exclude_me'
|
116
|
+
expect(scm_config.css('includedRegions').first.content).to eq 'included_region'
|
117
|
+
expect(scm_config.css('excludedRegions').first.content).to eq 'excluded_region'
|
118
|
+
end
|
72
119
|
end
|
73
120
|
|
74
|
-
|
75
|
-
|
121
|
+
context '<2.0' do
|
122
|
+
before :each do
|
123
|
+
JenkinsPipelineBuilder.registry.registry[:job][:scm_params].installed_version = '1.0'
|
124
|
+
end
|
76
125
|
|
77
|
-
|
126
|
+
it 'writes one block when both refspec and remote_name' do
|
127
|
+
params = { scm_params: { refspec: :bar, remote_name: :foo }, scm_url: 'http://foo.com' }
|
128
|
+
|
129
|
+
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
|
130
|
+
|
131
|
+
remote_config = @n_xml.root.children.first.children.first
|
132
|
+
|
133
|
+
expect(remote_config.name).to match 'hudson.plugins.git.UserRemoteConfig'
|
134
|
+
|
135
|
+
expect(remote_config.css('name').first).to be_truthy
|
136
|
+
expect(remote_config.css('refspec').first).to be_truthy
|
78
137
|
|
79
|
-
|
138
|
+
expect(remote_config.css('name').first.content).to eq 'foo'
|
139
|
+
expect(remote_config.css('refspec').first.content).to eq 'bar'
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'using remote_name does not remove the remote url' do
|
143
|
+
params = { scm_params: { remote_name: :foo }, scm_url: 'http://foo.com' }
|
144
|
+
|
145
|
+
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
|
80
146
|
|
81
|
-
|
147
|
+
remote_config = @n_xml.root.children.first.children.first
|
82
148
|
|
83
|
-
|
84
|
-
expect(remote_config.css('url').first).to be_truthy
|
149
|
+
expect(remote_config.name).to match 'hudson.plugins.git.UserRemoteConfig'
|
85
150
|
|
86
|
-
|
87
|
-
|
151
|
+
expect(remote_config.css('name').first).to be_truthy
|
152
|
+
expect(remote_config.css('url').first).to be_truthy
|
153
|
+
|
154
|
+
expect(remote_config.css('name').first.content).to eq 'foo'
|
155
|
+
expect(remote_config.css('url').first.content).to eq 'http://foo.com'
|
156
|
+
end
|
88
157
|
end
|
89
158
|
end
|
90
159
|
end
|
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.7.
|
4
|
+
version: 0.7.6
|
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: 2014-09-
|
12
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|